How to do it...

Perform the following steps to implement the example:

  1. First, implement your own worker thread class. Create a class named AlwaysThrowsExceptionWorkerThread that extends the ForkJoinWorkerThread class:
        public class AlwaysThrowsExceptionWorkerThread extends                                ForkJoinWorkerThread { 
  1. Implement the constructor of the class. It receives a ForkJoinPool class as a parameter and calls the constructor of its parent class:
        protected AlwaysThrowsExceptionWorkerThread(ForkJoinPool pool) {           super(pool);         } 
  1. Implement the onStart() method. This is a method of the ForkJoinWorkerThread class and is executed when the worker thread begins its execution. The implementation will throw a RuntimeException exception upon being called:
 protected ...

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.