|
|
@@ -7,6 +7,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
|
/**
|
|
|
* 创建单例线程池
|
|
|
+ *
|
|
|
* @author Andrews
|
|
|
* @date 2023/11/30 11:12
|
|
|
*/
|
|
|
@@ -18,7 +19,8 @@ public final class ThreadPoolExecutorFactory {
|
|
|
* CPU 密集型:核心线程数 = CPU核数 + 1
|
|
|
* IO 密集型:核心线程数 = CPU核数 * 2
|
|
|
*/
|
|
|
- private static final int CORE_POOL_SIZE = Runtime.getRuntime().availableProcessors() * 2;
|
|
|
+ private static final int CORE_POOL_SIZE =
|
|
|
+ Math.min(ThreadPoolExecutorFactory.MAX_IMUM_POOL_SIZE, Runtime.getRuntime().availableProcessors() * 2);
|
|
|
/**
|
|
|
* maximumPoolSize - 池中允许的最大线程数(采用LinkedBlockingQueue时没有作用)。
|
|
|
*/
|