perf: 优化关机退出

dev
huangfeng 1 year ago
parent 73913ebf3d
commit ffea7ebe68

@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Iterator;
@ -32,7 +33,13 @@ public class MntnCheckTask {
@Autowired
private CacheService cacheService;
StringBuilder sb;
private StringBuilder sb;
private int shutdown = 0;
@PreDestroy
private void preDestroy() {
shutdown = 1;
}
@Scheduled(initialDelay = 60000, fixedDelay = 60000)
private void checkAll() {
@ -41,7 +48,7 @@ public class MntnCheckTask {
sb = new StringBuilder();
Map<Integer, Terminals> terminalMap = cacheService.getTerminalMap();
Iterator<Integer> it = terminalMap.keySet().iterator();
while (it.hasNext()) {
while (shutdown == 0 && it.hasNext()) {
Integer termId = it.next();
this.checkOne(termId);
}

Loading…
Cancel
Save