Skip to content

Instantly share code, notes, and snippets.

@albertoaflores
Created November 30, 2019 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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