O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required