-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Java 9 Concurrency Cookbook, Second Edition
By :

The fork/join framework provides the ability to execute tasks that return a result. This kind of tasks is implemented by the RecursiveTask
class. This class extends the ForkJoinTask
class and implements the Future
interface provided by the Executor framework.
Inside the task, you have to use the structure recommended by the Java API documentation:
if (problem size > size){ tasks=Divide(task); execute(tasks); joinResults() return result; } else { resolve problem; return result; }
If the task has to resolve a problem bigger than a predefined size, you divide the problem into more subtasks and execute those subtasks using the fork/join framework. When they finish their execution, the initiating task obtains the results generated by all the subtasks, groups them, and returns the final result. Ultimately, when the initiating task executed in the pool finishes its execution, you obtain its result, which...