Hands-On High Performance with Spring 5
by Chintan Mehta, Subhash Shah, Pritesh Shah, Prashant Goswami, Dinesh Radadiya
Thread pool executor
You might wonder how we declare the thread pools that asynchronous methods will use. By default, for the thread pool, Spring will try to find either a unique TaskExecutor bean defined in the context or an Executor bean, named TaskExecutor. If neither of the preceding two options is resolvable, Spring will use SimpleAsyncTaskExecutor to process asynchronous method processing.
However, sometimes we do not want to use the same thread pool for all of the application's tasks. We can have different thread pools, with different configurations for each method. For that, we just need to pass the executor name to the @Async annotation for each method.
To enable asynchronous support, the @Async annotation is not enough; we need ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access