weixin_慕前端4079947
2019-06-27 20:28:07浏览 3380
package com.huihe.exam.configurer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
@Configuration
public class ScheduleConfig {
/**
* 日志
*/
private static final Logger LOGGER = LoggerFactory.getLogger(ScheduleConfig.class);
@Bean
public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
LOGGER.info("创建定时任务调度线程池 start");
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.setPoolSize(20);
threadPoolTaskScheduler.setThreadNamePrefix("taskExecutor-");
threadPoolTaskScheduler.setWaitForTasksToCompleteOnShutdown(true);
threadPoolTaskScheduler.setAwaitTerminationSeconds(60);
LOGGER.info("创建定时任务调度线程池 end");
return threadPoolTaskScheduler;
}
}