初始化时吧所有的都用了

This commit is contained in:
2025-04-05 17:43:22 +08:00
parent cecc7aa181
commit c8874064f0
3 changed files with 32 additions and 3 deletions

View File

@@ -0,0 +1,22 @@
package com.ycwl.basic.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
@Configuration
@EnableScheduling
public class SchedulerConfig {
@Bean
public ThreadPoolTaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(32); // 核心/最大线程数
scheduler.setAwaitTerminationSeconds(0); // 空闲线程存活时间(秒)
scheduler.setThreadNamePrefix("Scheduler-");
scheduler.setAwaitTerminationSeconds(60); // 等待任务终止的时间
scheduler.setRemoveOnCancelPolicy(true); // 取消任务后移除线程
return scheduler;
}
}