diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ThreadPoolAdapterRegister.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ThreadPoolAdapterRegister.java index bb39ea71..77101f5c 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ThreadPoolAdapterRegister.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ThreadPoolAdapterRegister.java @@ -66,18 +66,16 @@ public class ThreadPoolAdapterRegister implements ApplicationRunner { private List cacheConfigList = Lists.newArrayList(); - private static final int TASK_INTERVAL_SECONDS = 2; - @Override public void run(ApplicationArguments args) throws Exception { ScheduledExecutorService scheduler = threadPoolAdapterScheduler.getScheduler(); + int taskIntervalSeconds = threadPoolAdapterScheduler.getTaskIntervalSeconds(); + ThreadPoolAdapterRegisterTask threadPoolAdapterRegisterTask = new ThreadPoolAdapterRegisterTask(scheduler, taskIntervalSeconds); - ThreadPoolAdapterRegisterTask threadPoolAdapterRegisterTask = new ThreadPoolAdapterRegisterTask(scheduler); - - scheduler.schedule(threadPoolAdapterRegisterTask, TASK_INTERVAL_SECONDS, TimeUnit.SECONDS); + scheduler.schedule(threadPoolAdapterRegisterTask, threadPoolAdapterScheduler.getTaskIntervalSeconds(), TimeUnit.SECONDS); } public List getThreadPoolAdapterCacheConfigs(){ @@ -123,8 +121,11 @@ public class ThreadPoolAdapterRegister implements ApplicationRunner { private ScheduledExecutorService scheduler; - public ThreadPoolAdapterRegisterTask(ScheduledExecutorService scheduler){ + private int taskIntervalSeconds; + + public ThreadPoolAdapterRegisterTask(ScheduledExecutorService scheduler, int taskIntervalSeconds){ this.scheduler = scheduler; + this.taskIntervalSeconds = taskIntervalSeconds; } @Override @@ -166,7 +167,7 @@ public class ThreadPoolAdapterRegister implements ApplicationRunner { log.error("Register Task Error",e); }finally { if (!scheduler.isShutdown()) { - scheduler.schedule(this, TASK_INTERVAL_SECONDS, TimeUnit.MILLISECONDS); + scheduler.schedule(this, taskIntervalSeconds, TimeUnit.MILLISECONDS); } } }