Waiting for a subset of threads in a Java ThreadPool
- by David Semeria
Let's say I have a thread pool containing X items, and a given task employs Y of these items (where Y is much smaller than X).
I want to wait for all of the threads of a given task (Y items) to finish, not the entire thread pool.
If the thread pool's execute() method returned a reference to the employed thread I could simply join() to each of these Y threads, but it doesn't.
Does anyone know of an elegant way to accomplish this? Thanks.