Implementing the ThreadFactory interface to generate custom threads for the fork/join framework

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 ...

Get Java 9 Concurrency Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.