I am a bean for TaskScheduler and TaskExecutor as following:
@Bean
public TaskScheduler taskScheduler() {
ThreadPoolTaskScheduler s = new ThreadPoolTaskScheduler();
s.setThreadNamePrefix("Task-Scheduler-");
s.setPoolSize(10);
s.setRemoveOnCancelPolicy(true);
return s;
}
@Bean
public TaskExecutor taskExecutor() {
ThreadPoolTaskExecutor e = new ThreadPoolTaskExecutor();
e.setThreadNamePrefix("Task-Executor-");
e.setMaxPoolSize(10);
e.setCorePoolSize(10);
return e;
}
Is it possible to share the underlying thread pool executor service between the TaskExecutor and the TaskScheduler? Now I have twice a pool of each 10 fixed threads, but I would like to have one single pool of 20 threads.
These pools will be used for @Async, @Scheduled and @Retry annotatons.