Skip to content

Instantly share code, notes, and snippets.

@albertoaflores
Created November 30, 2019 12:37
Show Gist options
  • Save albertoaflores/121704e41d6becf94b25ce7d01ea797a to your computer and use it in GitHub Desktop.
Save albertoaflores/121704e41d6becf94b25ce7d01ea797a to your computer and use it in GitHub Desktop.
Generates a TaskExecutor to control the threads used in a given @async
@Bean(name = "myThreadPoolTaskExecutor")
public TaskExecutor threadPoolTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(4);
executor.setMaxPoolSize(4);
executor.setThreadNamePrefix("executor");
executor.initialize();
return executor;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment