I have a asynchronous method enabled using @Async annotation. At times i am seeing SimpleAsyncTaskExecutor thread count increases exponentially. Any idea on this behavior?
Asked
Active
Viewed 578 times
0
-
Have you configured CustomThreadPool? – Karthik Bharadwaj Feb 21 '17 at 06:18
-
No i haven't configured CustomThreadPool – Suraj Feb 22 '17 at 01:30
-
It is better if you configure the customThreadPool.Check this out. http://stackoverflow.com/questions/13206792/spring-async-limit-number-of-threads – Karthik Bharadwaj Feb 22 '17 at 07:52
2 Answers
0
If it increases literally exponentially it sounds like the async method is calling itself perhaps?

Viktor Mellgren
- 4,318
- 3
- 42
- 75
0
By default, Spring uses a SimpleAsyncTaskExecutor to run the methods asynchronously. SimpleAsyncTaskExecutor spawns a new thread with each task and does not support thread pooling and queueing of tasks. So, if the async method is called multiple times in a short span of time, multiple threads will be opened for each task You should define your own executor. Refer the following link http://www.baeldung.com/spring-async

eeedev
- 149
- 9