0

I have a asynchronous method enabled using @Async annotation. At times i am seeing SimpleAsyncTaskExecutor thread count increases exponentially. Any idea on this behavior?

rajadilipkolli
  • 3,475
  • 2
  • 26
  • 49
Suraj
  • 97
  • 5

2 Answers2

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