Summary
The divide and conquer design technique is a very popular approach to solve different kinds of problems. You divide the original problem into smaller problems and those problems into smaller ones until you have enough simple problems to solve them directly. In version 7, the Java Concurrency API introduced a special kind of Executor
optimized for this kind of problem, namely the fork/join framework. It's based on the fork operations, that allows you to create a new child task, and the join
operation, that allows you to wait for the finalization of a child task before getting its results.
Using those operations, your fork/join tasks will have the following appearance:
if ( problem.size() > DEFAULT_SIZE) { childTask1=new Task(); childTask2=new Task(); childTask1.fork(); childTask2.fork(); childTaskResults1=childTask1.join(); childTaskResults2=childTask2.join(); taskResults=makeResults(childTaskResults1, childTaskResults2); return taskResults; } else { taskResults...