|
@@ -30,6 +30,9 @@ public class MyThreadPool extends ThreadPoolTaskExecutor {
|
|
|
@Value("${sys.config.threadPoolCoreSize}")
|
|
|
Integer threadPoolCoreSize;
|
|
|
|
|
|
+ @Value("${sys.config.customThreadPoolCoreSize}")
|
|
|
+ boolean customThreadPoolCoreSize;
|
|
|
+
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
taskThreadPool();
|
|
@@ -45,7 +48,7 @@ public class MyThreadPool extends ThreadPoolTaskExecutor {
|
|
|
if (Objects.isNull(threadPoolTaskExecutor)) {
|
|
|
log.info("cpuNum:{}", cpuNum);
|
|
|
threadPoolTaskExecutor = new MyThreadPool();
|
|
|
- if (cpuNum > 0) {
|
|
|
+ if (!customThreadPoolCoreSize && cpuNum > 0) {
|
|
|
threadPoolTaskExecutor.setCorePoolSize(cpuNum);//核心线程数
|
|
|
threadPoolTaskExecutor.setMaxPoolSize(cpuNum * 2);//最大线程数
|
|
|
} else {
|