tags:

views:

126

answers:

3

Can someone explain what Fork/Join is?

+2  A: 

Say you have a collection of things that need to be processed. You have a number of threads that can grab subsets of this collection and process them. They all do this concurrently (the fork part) then wait on the last one to finish (the join part) before returning.

Nathan Hughes
With the priviso that the current parent _stops executing_ until all the concurrent workers complete, and _then_ resumes. I know this was inherent in your description, but I think it's worth being very explicit because that's about all that really makes this differ from any other kind of explicit parallelism.
Gian
Well, it's not fork a load of operations, perform them all and then join. It's a divide-and-conquer approach.
Tom Hawtin - tackline
+2  A: 

Fork Join is a new framework that has an easier to use API for a parallel, divide and conquer algorithm.

Say you have a long running task that, for this instance, has a complicated algorithm. You would want to fork the large tasks and now work on those two tasks. Now lets say that that those two tasks are still too big, you would fork each into two tasks (at this point there are four).

You would continue this until each task is at an acceptable size and invoke the algorithm. It is important to know the invocation of each task is done in parallel. When the task is completed it is joined with the other task it was forked with and consolidate the results.

This will continue until all tasks have been joined and one task is returned.

John V.