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

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.