@Bean
protected ThreadPoolExecutor threadPoolExecutor() {
ThreadPoolExecutor executor = new ThreadPoolExecutor(
corePoolSize, //核心线程数
maxPoolSize, //最大线程数
keepAliveSeconds, //空闲线程存活时间
TimeUnit.SECONDS, //单位
new LinkedBlockingDeque<>(1000000),//队列长度
Executors.defaultThreadFactory(),//线程工厂
new ThreadPoolExecutor.AbortPolicy()//拒绝策略
);
return executor;
}
自定义线程池ThreadPoolExecutor
最新推荐文章于 2024-06-02 17:50:48 发布