I am running several spring batch partitioning jobs from within the same JVM instance. Each is configured to use 3 threads but every time a new job starts I see in the logs that SimpleAsyncTaskExecutor keeps increasing its thread number.
so first jobs shows:
09:53:02.370 [SimpleAsyncTaskExecutor-1] INFO...
09:53:02.370 [SimpleAsyncTaskExecutor-2] INFO...
and next jobs shows:
09:53:02.370 [SimpleAsyncTaskExecutor-3] INFO...
09:53:02.370 [SimpleAsyncTaskExecutor-4] INFO...
I would have expected each new job to use threads 1 and 2 and not create new ones...I am shutting down the job each time but can post code if needed.
SimpleAsyncTaskExecutor does not reuse threads. Furthermore SimpleAsyncTaskExecutor by default creates unlimited threads.
For reuse threads you need to use ThreadPoolTaskExecutor.
Read below for more information:
https://egkatzioura.com/2017/10/25/spring-and-threads-taskexecutor/
https://egkatzioura.com/2017/10/25/spring-and-async/
https://egkatzioura.com/2017/10/25/spring-and-threads-transactions/
How to control the number of parallel Spring Batch jobs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With