One of the most interesting features of Java 9 is the fork/join framework. It's an implementation of the Executor and ExecutorService interfaces that allows you to execute the Callable and Runnable tasks without managing the threads that execute them.
This executor is oriented to execute tasks that can be divided into smaller parts. Its main components are as follows:
- It's a special kind of task, which is implemented by the ForkJoinTask class.
- It provides two operations for dividing a task into subtasks (the fork operation) and to wait for the finalization of these subtasks (the join operation).
- It's an algorithm, denominating the work-stealing algorithm, that optimizes the use of the threads of the pool. When a task waits for its subtasks, the thread that was executing it is used to execute another thread...