Browse Source

优化多线程参数

pull/249/head
648540858 3 years ago
parent
commit
be7082f5e2
  1. 8
      src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java

8
src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java

@ -11,6 +11,8 @@ import java.util.concurrent.ThreadPoolExecutor;
@EnableAsync(proxyTargetClass = true)
public class ThreadPoolTaskConfig {
public static final int cpuNum = Runtime.getRuntime().availableProcessors();
/**
* 默认情况下在创建了线程池后线程池中的线程数为0当有任务来之后就会创建一个线程去执行任务
* 当线程池中的线程数目达到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;
/**
* 线程池名前缀
*/

Loading…
Cancel
Save