[concurrency-interest] Use-cases and issues with the ForkJoinPool

Doug Lea dl at cs.oswego.edu
Mon Jan 16 11:45:46 EST 2012

On 01/16/12 10:48, Romain Colle wrote:
> I guess the more general question I had was: why does a joining thread
> goes into idle wait (pool.tryAwaitJoin()) if it has a non-empty queue?
> I'd like to at least see it "steal" from anywhere in its own queue,
> and even go for helpJoinTask().

Yet more deja vu. There was initially a FJT method "helpJoin"
that did exactly this, but had a disclaimer that your task
graph must be a dag, and that only the callers of forks
ever perform joins. This is fact the most common case, but
people were concerned that the restrictions were hard
to understand (and unenforceable). We should have at least
documented how to recreate it from the methods that
we do support. The following should suffice for most purposes:

     public V helpJoin() {
         ForkJoinTask<?> t;
         while (!isDone() && (t = pollLocalTask()) != null)
         return join();


More information about the Concurrency-interest mailing list