My question is very similar to this one : @Async prevent a thread to continue until other thread have finished
Basically i need run ~ hundreds of computations in more threads. I want to run only some amount of parallel threads e.g. 5 threads with 5 computationis in paralell.
I am using spring framework and @Async option is natural choice. I do not need full-featured JMS queue, that`s a bit overhead for me.
Any ideas ?
Thank you
Have you checked out
Task Executor? You can define a Thread Pool, with a maximum number of threads to execute your tasks.If you want to use it with
@Async, use this in your spring-config:Full reference here (25.5.3). Hope this helps.