修改线程池

This commit is contained in:
zren25
2025-05-27 17:31:17 +08:00
parent 4c2477d454
commit 3e456d2f00

View File

@@ -25,12 +25,10 @@ public class ExecutorConfig {
@Bean("threadPoolTaskExecutor") @Bean("threadPoolTaskExecutor")
public ThreadPoolTaskExecutor corpusProcessExecutor() { public ThreadPoolTaskExecutor corpusProcessExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
int corePoolSize = Runtime.getRuntime().availableProcessors() + 2;
executor.setCorePoolSize(corePoolSize); executor.setCorePoolSize(corePoolSize);
executor.setMaxPoolSize(maxPoolSize); executor.setMaxPoolSize(maxPoolSize);
executor.setQueueCapacity(queueCapacity); executor.setQueueCapacity(queueCapacity);
executor.setThreadNamePrefix("corpus-process-pool-"); executor.setThreadNamePrefix("Thread-process-pool-");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.setKeepAliveSeconds(keepAliveSeconds); executor.setKeepAliveSeconds(keepAliveSeconds);
executor.initialize(); executor.initialize();