blue
2 years ago
committed by
Gitee
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with
3 additions and
1 deletions
-
im-commom/src/main/java/com/bx/imcommon/util/ThreadPoolExecutorFactory.java
|
|
|
@ -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时没有作用)。 |
|
|
|
*/ |
|
|
|
|