[concurrency-interest] Handling DAGs with JSR166

Doug Lea dl at cs.oswego.edu
Mon Nov 15 19:01:57 EST 2010

On 11/15/10 13:38, Niko Matsakis wrote:
> The idea is that each task represents a node in the DAG. I
> don't know the DAG before hand, so I need to run the tasks to find out who will
> join which other tasks. ...
> Clearly I am violating some assumption.
> Is there a better way to handle encode such a problem with jsr166y?

The provided Recursive{Action,Task} subclasses of ForkJoinTask deal
with strict nesting, but you can use others for arbitrary
DAGS. Two such classes (BinaryAsyncAction and LinkedAsyncAction),
along with a few usage examples can be found in our CVS at

We initially planned to include these and others in the main
package, but found that whenever people were tempted
to use them, they ended up making custom ForkJoinTask classes
using some combination of join counts, parent links,
phasers, and/or quiescence detection. One of these days we should
put together a tutorial about these kinds of mechanics.


More information about the Concurrency-interest mailing list