work线程池优化

This commit is contained in:
1115900427@qq.com 2024-09-06 21:25:28 +08:00
parent eb2bc63240
commit 1e0f6a88a0

View File

@ -25,8 +25,12 @@ public class ThreadPoolCache {
public static ThreadPoolExecutor createThreadPool(Long taskBatchId, int parallelNum) {
if (CACHE_THREAD_POOL.containsKey(taskBatchId)) {
ThreadPoolExecutor threadPoolExecutor = CACHE_THREAD_POOL.get(taskBatchId);
threadPoolExecutor.setCorePoolSize(parallelNum);
threadPoolExecutor.setMaximumPoolSize(parallelNum);
if (threadPoolExecutor.getCorePoolSize() == parallelNum) {
return threadPoolExecutor;
} else {
threadPoolExecutor.setCorePoolSize(parallelNum);
threadPoolExecutor.setMaximumPoolSize(parallelNum);
}
return threadPoolExecutor;
}