@Configuration
public class CouponTaskThreadPoolConfig {
@Bean("couponTaskExecutor")
public ExecutorService couponTaskExecutor() {
ThreadFactory threadFactory = new ThreadFactory() {
private final AtomicInteger threadNumber = new AtomicInteger(1);
@Override
public Thread newThread(Runnable r) {
Thread thread = new Thread(r, "coupon-task-pool-" + threadNumber.getAndIncrement());
thread.setDaemon(false);
return thread;
}
};
return new ThreadPoolExecutor(
5,
20,
60L,
TimeUnit.SECONDS,
new LinkedBlockingQueue<>(100),
threadFactory,
new ThreadPoolExecutor.CallerRunsPolicy()
);
}
}
线程池创建模版
小小小米粒2026-05-08 9:18
相关推荐
ps酷教程5 小时前
Jackson 解决没有无参构造函数的反序列化问题NiceCloud喜云5 小时前
Opus 4.8 的 Effort Control 怎么选:Low 到 Max 五档策略_日拱一卒6 小时前
LeetCode:994腐烂的橘子隔窗听雨眠6 小时前
Nginx网关响应慢排查手记智慧物业老杨6 小时前
智慧物业合同周期管理系统:从风险预警到智能交接的全流程数智化落地方案源码宝7 小时前
MES系统源码:Java8 + SpringBoot2.7 + MySQL8 + Redis,后端源码清爽易扩展JAVA社区7 小时前
Java高级全套教程(十)—— SpringCloudAlibaba超详细实战详解金銀銅鐵7 小时前
[Java] 如何理解 class 文件中方法的 descriptor?云烟成雨TD7 小时前
Spring AI Alibaba 1.x 系列【63】AI Agent 长期记忆憧憬成为java架构高手的小白8 小时前
苍穹外卖--day09