[英]Issue with Spring Boot Async method
I have a asynchronous method enabled using @Async annotation. 我使用@Async批注启用了异步方法。 At times i am seeing SimpleAsyncTaskExecutor thread count increases exponentially.
有时我看到SimpleAsyncTaskExecutor线程计数呈指数增长。 Any idea on this behavior?
对这种行为有任何想法吗?
如果它从字面上按指数级增长,这听起来像是异步方法正在调用自身?
By default, Spring uses a SimpleAsyncTaskExecutor to run the methods asynchronously. 默认情况下,Spring使用SimpleAsyncTaskExecutor异步运行方法。 SimpleAsyncTaskExecutor spawns a new thread with each task and does not support thread pooling and queueing of tasks.
SimpleAsyncTaskExecutor随每个任务生成一个新线程,并且不支持线程池和任务排队。 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.
因此,如果在短时间内多次调用async方法,则将为每个任务打开多个线程。您应该定义自己的执行程序。 Refer the following link http://www.baeldung.com/spring-async
请参考以下链接http://www.baeldung.com/spring-async
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.