Ver código fonte

【CHG】修改线程池配置

ZhaoMn 3 anos atrás
pai
commit
d021c84f1e

+ 3 - 2
railway-framework/src/main/java/com/railway/framework/config/ConfigurerSchedulingTask.java

@@ -1,15 +1,16 @@
 package com.railway.framework.config;
 
+import java.util.concurrent.ScheduledExecutorService;
 import javax.annotation.Resource;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.SchedulingConfigurer;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.scheduling.config.ScheduledTaskRegistrar;
 import org.springframework.scheduling.support.CronTrigger;
 
 /**
  * 基于接口SchedulingConfigurer的动态定时任务
+ * @author fenghao
  */
 @Configuration
 @EnableScheduling
@@ -29,7 +30,7 @@ public abstract class ConfigurerSchedulingTask implements SchedulingConfigurer {
    */
   @Override
   public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
-    ThreadPoolTaskExecutor executor = threadConfig.threadPoolTaskExecutor();
+    ScheduledExecutorService executor = threadConfig.scheduledExecutorService();
     taskRegistrar.setScheduler(executor);
     taskRegistrar.addTriggerTask(
         //执行定时任务

+ 0 - 2
railway-framework/src/main/java/com/railway/framework/config/ThreadPoolConfig.java

@@ -65,8 +65,6 @@ public class ThreadPoolConfig {
 
   /**
    * 执行周期性或定时任务
-   * 关于ScheduledThreadPoolExecutor和ThreadPoolTaskScheduler有点难以分辨,但是它们二者其实也是互斥的。
-   * ThreadPoolTaskScheduler定时功能更强大一些,可以自定义trigger,而ScheduledThreadPoolExecutor的定时确没这么灵活。
    */
   @Bean(name = "scheduledExecutorService")
   protected ScheduledExecutorService scheduledExecutorService() {