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

In this recipe, you have implemented the following elements:

  • Your own worker thread class: You have implemented the AlwaysThrowsExceptionWorkerThread class, which extends the ForkJoinWorkerThread class, which implements the worker threads of a fork/join pool. You have overridden the onStart() method. This method is executed when a worker thread starts its execution. It simply throws an exception RuntimeException upon being called.
  • Your own thread factory: A ForkJoinPool class creates its worker threads using a factory. As you want to create a ForkJoinPool object that uses the AlwaysThrowsExceptionWorkerThreadFactory worker threads, you have implemented a factory that creates them. To implement a worker thread factory, you ...

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