我有两个ThreadPoolExecutors
。第一个,在afterPropertiesSet()
:
ThreadPoolTaskExecutor firstTaskExecutor = null;
然后
this.firstTaskExecutor= new ThreadPoolTaskExecutor();
this.firstTaskExecutor.setBeanName("reports");
this.firstTaskExecutor.setMaxPoolSize(3);
this.firstTaskExecutor.setQueueCapacity(200);
this.firstTaskExecutor
.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
this.firstTaskExecutor.afterPropertiesSet();
this.firstTaskExecutor.setWaitForTasksToCompleteOnShutdown(true);
第二个是通过其他控制器中的Bean
连线:
@Bean
public TaskExecutor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(4);
executor.setMaxPoolSize(4);
executor.setThreadNamePrefix("EMAILS");
executor.initialize();
return executor;
}
将第二个添加到代码后,第一个TaskExecutor执行的所有任务似乎只由一个线程处理,这意味着第二个池正在影响第一个。
这可能是这个原因吗?