From 6881da91d8a141800e4e1b098f0dcdf2d2b60af6 Mon Sep 17 00:00:00 2001 From: smile <1372184840@qq.com> Date: Mon, 1 Dec 2025 16:49:32 +0800 Subject: [PATCH] refactor(threadpool): refactor ThreadPoolTaskExecutor --- .../bgasol/common/core/base/config/ThreadPoolConfig.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cloud/common/common-base-web/src/main/java/com/bgasol/common/core/base/config/ThreadPoolConfig.java b/cloud/common/common-base-web/src/main/java/com/bgasol/common/core/base/config/ThreadPoolConfig.java index 431c44e..fbf87e1 100644 --- a/cloud/common/common-base-web/src/main/java/com/bgasol/common/core/base/config/ThreadPoolConfig.java +++ b/cloud/common/common-base-web/src/main/java/com/bgasol/common/core/base/config/ThreadPoolConfig.java @@ -16,13 +16,13 @@ public class ThreadPoolConfig { */ @Bean("cpuThreadPool") public ThreadPoolTaskExecutor cpuThreadPool() { - int cores = Runtime.getRuntime().availableProcessors() / 2; + int cores = Runtime.getRuntime().availableProcessors(); int corePoolSize = cores + 1; ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(corePoolSize); executor.setMaxPoolSize(corePoolSize); executor.setQueueCapacity(500); - executor.setThreadNamePrefix("cpu-pool"); + executor.setThreadNamePrefix("cpu-pool-"); executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); executor.setAllowCoreThreadTimeOut(true); executor.initialize(); @@ -35,14 +35,13 @@ public class ThreadPoolConfig { */ @Bean("ioThreadPool") public ThreadPoolTaskExecutor ioThreadPool() { - int cores = Runtime.getRuntime().availableProcessors() / 2; + int cores = Runtime.getRuntime().availableProcessors(); int corePoolSize = cores * 2; - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(corePoolSize); executor.setMaxPoolSize(corePoolSize); executor.setQueueCapacity(2000); - executor.setThreadNamePrefix("io-pool"); + executor.setThreadNamePrefix("io-pool-"); executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); executor.setAllowCoreThreadTimeOut(true); executor.initialize();