2013年4月22日 星期一

ThreadPoolExecutor waitForTasksToCompleteOnShutdown doesn't work as expected

https://jira.springsource.org/browse/SPR-5387


ThreadPoolTaskExecutor doesn't work when setting up the WaitForTasksToCompleteOnShutdown property as true, also need to set up the AwaitTerminationSeconds property.


@Bean
public ThreadPoolTaskExecutor processTaskExecutor() {
   ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
   taskExecutor.setCorePoolSize(5);
   taskExecutor.setMaxPoolSize(10);
   taskExecutor.setQueueCapacity(40);
   taskExecutor.setKeepAliveSeconds(200);
   taskExecutor.setWaitForTasksToCompleteOnShutdown(true);
   taskExecutor.setAwaitTerminationSeconds(60);
   taskExecutor.setThreadFactory(new CustomizableThreadFactory("DeployThread"));
   return taskExecutor;
}

沒有留言: