fix: 设置线程池并发数量,防止抢占过多系统资源

This commit is contained in:
taojinlong 2024-09-11 15:44:00 +08:00
parent 39e267fc2d
commit 0e46b48420

View File

@ -15,6 +15,8 @@ public class CommonThreadPool {
private int maxQueueSize = 10;
private int maximumPoolSize = 10;
private int keepAliveSeconds = 600;
private ScheduledThreadPoolExecutor scheduledThreadPoolExecutor;
@ -22,6 +24,7 @@ public class CommonThreadPool {
@PostConstruct
public void init() {
scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(corePoolSize);
scheduledThreadPoolExecutor.setMaximumPoolSize(maximumPoolSize);
scheduledThreadPoolExecutor.setKeepAliveTime(keepAliveSeconds, TimeUnit.SECONDS);
}