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) {
|
public static ThreadPoolExecutor createThreadPool(Long taskBatchId, int parallelNum) {
|
||||||
if (CACHE_THREAD_POOL.containsKey(taskBatchId)) {
|
if (CACHE_THREAD_POOL.containsKey(taskBatchId)) {
|
||||||
ThreadPoolExecutor threadPoolExecutor = CACHE_THREAD_POOL.get(taskBatchId);
|
ThreadPoolExecutor threadPoolExecutor = CACHE_THREAD_POOL.get(taskBatchId);
|
||||||
threadPoolExecutor.setCorePoolSize(parallelNum);
|
if (threadPoolExecutor.getCorePoolSize() == parallelNum) {
|
||||||
threadPoolExecutor.setMaximumPoolSize(parallelNum);
|
return threadPoolExecutor;
|
||||||
|
} else {
|
||||||
|
threadPoolExecutor.setCorePoolSize(parallelNum);
|
||||||
|
threadPoolExecutor.setMaximumPoolSize(parallelNum);
|
||||||
|
}
|
||||||
return threadPoolExecutor;
|
return threadPoolExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user