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;
}