修改线程池
This commit is contained in:
@@ -30,7 +30,7 @@ public class ExecutorConfig {
|
||||
@Bean("threadPoolTaskExecutor")
|
||||
@Primary
|
||||
public ThreadPoolTaskExecutor corpusProcessExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(corePoolSize);
|
||||
executor.setMaxPoolSize(maxPoolSize);
|
||||
executor.setQueueCapacity(queueCapacity);
|
||||
@@ -38,14 +38,13 @@ public class ExecutorConfig {
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
executor.setKeepAliveSeconds(keepAliveSeconds);
|
||||
executor.initialize();
|
||||
this.executor = executor;
|
||||
return executor;
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
if (executor != null) {
|
||||
log.info("Shutting down thread pool: {}", executor);
|
||||
log.info("Thread-process-pool-ShuttingDown: {}", executor);
|
||||
ThreadPoolExecutor threadPoolExecutor = this.executor.getThreadPoolExecutor();
|
||||
threadPoolExecutor.shutdownNow(); // 强制关闭所有正在执行的任务
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user