优化多线程参数

pull/249/head
648540858 2021-11-25 15:33:25 +08:00
parent 59e369e37d
commit be7082f5e2
1 changed files with 5 additions and 3 deletions

View File

@ -11,6 +11,8 @@ import java.util.concurrent.ThreadPoolExecutor;
@EnableAsync(proxyTargetClass = true) @EnableAsync(proxyTargetClass = true)
public class ThreadPoolTaskConfig { public class ThreadPoolTaskConfig {
public static final int cpuNum = Runtime.getRuntime().availableProcessors();
/** /**
* 线线线0线 * 线线线0线
* 线线corePoolSize * 线线corePoolSize
@ -20,11 +22,11 @@ public class ThreadPoolTaskConfig {
/** /**
* 线线 * 线线
*/ */
private static final int corePoolSize = 5; private static final int corePoolSize = cpuNum;
/** /**
* 线 * 线
*/ */
private static final int maxPoolSize = 30; private static final int maxPoolSize = cpuNum*2;
/** /**
* 线 * 线
*/ */
@ -32,7 +34,7 @@ public class ThreadPoolTaskConfig {
/** /**
* *
*/ */
private static final int queueCapacity = 10000; private static final int queueCapacity = 500;
/** /**
* 线 * 线
*/ */