@Configuration @EnableAsync public class TaskExecutorConfig { @Bean public Executor taskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); // 设置核心线程数 executor.setCorePoolSize(10); // 设置最大线程数 executor.setMaxPoolSize(20); // 设置队列容量 executor.setQueueCapacity(Integer.MAX_VALUE); // 设置线程活跃时间(秒) executor.setKeepAliveSeconds(120); // 设置默认线程名称 executor.setThreadNamePrefix("member-thread"); // 设置拒绝策略 executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); executor.initialize(); return executor; } }
springboot线程池配置核心参数
最新推荐文章于 2024-07-28 09:59:00 发布
关键词由CSDN通过智能技术生成