We have three different multi threading techniques in java - Fork/Join pool, Executor Service & CountDownLatch
Fork/Join pool (http://www.javacodegeeks.com/2011/02/java-forkjoin-parallel-programming.html)
The Fork/Join framework is designed to make divide-and-conquer algorithms easy to parallelize. That type of algorithms is perfect for problems that can be divided into two or more sub-problems of the same type. They use recursion to break down the problem to simple tasks until these become simple enough to be solved directly. The solutions to the sub-problems are then combined to give a solution to the original problem
ExecutorService is an interface that extends Executor class and represents an asynchronous execution. It provides us mechanisms to manage the end and detect progress of the asynchronous tasks.
invokeAll() : Executes the given tasks, returning a list of Futures holding their status and results when all complete. Future.isDone() is true for each element of the returned list.
CountDownLatch:(http://examples.javacodegeeks.com/core-java/util/concurrent/countdownlatch-concurrent/java-util-concurrent-countdownlatch-example/)
CountDownLatch is used in synchronisation to allow one or more threads to wait until a set of operations being performed in other threads completes.
My assumption:
In both these alternatives, final result will be known only after completion of all tasks/threads.
Are these three alternatives complimentary or supplementary to each other?