Waiting for a subset of threads in a Java ThreadPool

Posted by David Semeria on Stack Overflow See other posts from Stack Overflow or by David Semeria
Published on 2011-01-08T17:51:38Z Indexed on 2011/01/08 17:53 UTC
Read the original article Hit count: 145

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about java

Related posts about concurrency