I use the Executor framework to start multiple threads using threadpool ie newFixedThreadPool. I use threadpool.submit (aThread) to submit jobs that will be executed using threadpool, and this works fine, but I need to determine when all threads are complete so that I can continue processing. I looked at using Future.get (), which blocks until the thread is completed, and the problem will be that it blocks until the result is received. I also looked at using a continuous call to the isTerminated () method, followed by hibernation after issuing a shutdown, to check if all threads are complete, but that doesn't seem neat to me. Is there an even cleaner way? Also, if there is any exception that has occurred in any of the threads, I wantso that you can complete all other running threads, as well as stop starting any queue in the pool from the pool. What is the best mechanism for doing this?
We look forward to hearing from you.
TIA
Ketan source
share