!88 work线程池优化
优化线程池,当work节点有重复批次任务的时候,再启动并行度。 修复jdk8客户端不兼容springboot2.0
This commit is contained in:
parent
16a6d8e778
commit
9bec12a27f
@ -24,13 +24,20 @@ 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);
|
||||
if (threadPoolExecutor.getCorePoolSize() == parallelNum) {
|
||||
return threadPoolExecutor;
|
||||
} else {
|
||||
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