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,319
  • 1
  • 24
  • 47
Suraj
  • 87
  • 4

2 Answers2

0

If it increases literally exponentially it sounds like the async method is calling itself perhaps?

Viktor Mellgren
  • 4,132
  • 3
  • 41
  • 71
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
  • 141
  • 8