Java 7 introduced a specialized executor service, namely, the fork-join API. It dynamically manages the number of threads, based on the available processors, and other parameters such as the number of concurrent tasks. It also employs an important pattern, work stealing—we will soon discuss this.
The fork-join pool
Egrep – simple version
Let's see the fork-join API in action. We will look at two examples to understand how the API works. The idea is to find a word in a text file. The driver class is EgrepWord:
public class EgrepWord {
private final static ForkJoinPool forkJoinPool = new ForkJoinPool();
The principal theme in the fork-join API is a recursive task. The following class extends...