fix:(1.2.0-beta2): 修复客户端获取线程时的并发问题

This commit is contained in:
srzou 2024-09-20 16:38:29 +08:00
parent 580686dd6b
commit ada892157d

View File

@ -45,7 +45,11 @@ public class ThreadPoolCache {
};
ThreadPoolExecutor threadPoolExecutor = supplier.get();
CACHE_THREAD_POOL.putIfAbsent(taskBatchId, threadPoolExecutor);
ThreadPoolExecutor cacheThreadPoolExecutor = CACHE_THREAD_POOL.putIfAbsent(taskBatchId, threadPoolExecutor);
if (Objects.nonNull(cacheThreadPoolExecutor) && cacheThreadPoolExecutor != threadPoolExecutor) {
cacheThreadPoolExecutor.setCorePoolSize(Math.min(parallelNum, cacheThreadPoolExecutor.getMaximumPoolSize()));
return cacheThreadPoolExecutor;
}
return threadPoolExecutor;
}