Processing uncontrolled exceptions in a ForkJoinPool class

The fork/join framework gives you the possibility to set a handler for the exceptions thrown by the worker threads of a ForkJoinPool class. When you work with a ForkJoinPool class, you should understand the difference between tasks and worker threads.

To work with the fork/join framework, you implement a task extending the ForkJoinTask class or, usually, the RecursiveAction or RecursiveTask classes. The task implements the actions you want to execute concurrently with the framework. They are executed in the ForkJoinPool class by the worker threads. A worker thread will execute various tasks. In the work-stealing algorithm implemented by the ForkJoinPool class, a worker thread looks ...

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.