优化线程池,当work节点有重复批次任务的时候,再启动并行度。
This commit is contained in:
parent
97f4bd9ebd
commit
eb2bc63240
@ -24,13 +24,16 @@ public class ThreadPoolCache {
|
||||
|
||||
public static ThreadPoolExecutor createThreadPool(Long taskBatchId, int parallelNum) {
|
||||
if (CACHE_THREAD_POOL.containsKey(taskBatchId)) {
|
||||
return CACHE_THREAD_POOL.get(taskBatchId);
|
||||
ThreadPoolExecutor threadPoolExecutor = CACHE_THREAD_POOL.get(taskBatchId);
|
||||
threadPoolExecutor.setCorePoolSize(parallelNum);
|
||||
threadPoolExecutor.setMaximumPoolSize(parallelNum);
|
||||
return threadPoolExecutor;
|
||||
}
|
||||
|
||||
Supplier<ThreadPoolExecutor> supplier = () -> {
|
||||
|
||||
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
|
||||
parallelNum, parallelNum, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
|
||||
1, 1, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
|
||||
new CustomizableThreadFactory(MessageFormat.format("snail-job-job-{0}-", taskBatchId)));
|
||||
threadPoolExecutor.allowCoreThreadTimeOut(true);
|
||||
return threadPoolExecutor;
|
||||
|
Loading…
Reference in New Issue
Block a user