work线程池优化
This commit is contained in:
parent
eb2bc63240
commit
1e0f6a88a0
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user