How to do it...

Follow these steps to implement the example:

  1. First, extend the ThreadGroup class by creating a class called MyThreadGroup that would be extended from ThreadGroup. You have to declare a constructor with one parameter because the ThreadGroup class doesn't have a constructor without it. Extend the ThreadGroup class to override the uncaughtException() method in order to process the exceptions thrown by the threads of the group:
        public class MyThreadGroup extends ThreadGroup {           public MyThreadGroup(String name) {             super(name);           }
  1. Override the uncaughtException() method. This method is called when an exception is thrown in one of the threads of the ThreadGroup class. In this case, the method will write information about the ...

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.