扩大线程池
This commit is contained in:
parent
66c2b5c73a
commit
1a7634b9a6
@ -47,7 +47,7 @@ public class SimStatusChecker {
|
||||
@Resource(name = "local")
|
||||
private DeviceService deviceService;
|
||||
|
||||
private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(3);
|
||||
@Autowired
|
||||
private SimCardQueryServiceImpl simCardQueryServiceImpl;
|
||||
|
||||
@ -56,12 +56,12 @@ public class SimStatusChecker {
|
||||
@Scheduled(cron = "0 */10 * * * ?")
|
||||
private void scheduleSimCardStatusCheck() {
|
||||
List<GnssStatusJoin> onlineDevices = gnssStatusMapper.queryOnline();
|
||||
logger.debug("当前在线设备数量: {}", onlineDevices.size());
|
||||
logger.info("当前在线设备数量: {}", onlineDevices.size());
|
||||
|
||||
for (GnssStatusJoin onlineDevice : onlineDevices) {
|
||||
//int delay = Math.abs(onlineDevice.getDeviceid().hashCode() % 3600 );
|
||||
int delay = Math.abs(onlineDevice.getDeviceid().hashCode() % 600 );
|
||||
logger.debug("设备: {}, SIM状态查询,延迟执行: {}秒", onlineDevice.getDeviceid(), delay);
|
||||
logger.info("- 设备: {}, SIM状态查询,延迟执行: {}秒", onlineDevice.getDeviceid(), delay);
|
||||
|
||||
scheduler.schedule(() -> checkDeviceSimCardStatus(onlineDevice.getDeviceid()),
|
||||
delay, TimeUnit.SECONDS);
|
||||
@ -73,11 +73,11 @@ public class SimStatusChecker {
|
||||
@Scheduled(cron = "0 */20 * * * ?")
|
||||
private void scheduleSimCardTrafficCheck() {
|
||||
List<GnssStatusJoin> onlineDevices = gnssStatusMapper.queryOnline();
|
||||
logger.debug("当前在线设备数量: {}", onlineDevices.size());
|
||||
logger.info("当前在线设备数量: {}", onlineDevices.size());
|
||||
|
||||
for (GnssStatusJoin onlineDevice : onlineDevices) {
|
||||
int delay = Math.abs(onlineDevice.getDeviceid().hashCode() % 1200);
|
||||
logger.debug("设备: {}, SIM流量查询,延迟执行: {}秒", onlineDevice.getDeviceid(), delay);
|
||||
logger.debug("- 设备: {}, SIM流量查询,延迟执行: {}秒", onlineDevice.getDeviceid(), delay);
|
||||
|
||||
scheduler.schedule(() -> checkDeviceSimCardTraffic(onlineDevice.getDeviceid()),
|
||||
delay, TimeUnit.SECONDS);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user