I\'m using Spring 4.3.8.RELEASE with Java 7. I want to create a thread pool to execute tasks so I have set up the following in my Spring contxet
Be aware of using the default ThreadPoolTaskExecutor
if many @Async
tasks are executed.
As of Spring Boot 2.1 there is a default ThreadPoolTaskExecutor
with a default core size of eight threads. Although the max pool size is still infinity¹ and new threads can be theoretically created the queue size of this pool is infinity¹ as well.
The queue size will probably never hit and new threads will never be created.
At least set the queue size if @Async
is used:
spring.task.execution.pool.queue-capacity=16
¹ infinity as in 2147483647 a.k.a. Integer.MAX_VALUE