java - Spring 3.x - @Async methods not called concurrently by task executor - Stack Overflow
The issue is that you're calling the methods internally so they're not proxied. For the @Async
to work you need to retrieve the object from your application context and invoke the methods on the retrieved copy. Invoking it internally will not work.
The same thing happens if you try to invoke internal @Transactional
methods. See the Note: section at the end of the Spring docs explaining @Transactional
for details.
Additionally, the way you're immediately calling .get()
on the Future
return values is incorrect. If you want them to happen in parallel you should submit all the tasks then retrieve each one via .get()
.
Read full article from java - Spring 3.x - @Async methods not called concurrently by task executor - Stack Overflow
No comments:
Post a Comment