How it works...

In the following screenshot, you can see the output of the list() method of the ThreadGroup class and the output generated when we write the status of each Thread object:

The ThreadGroup class stores thread objects and other ThreadGroup objects associated with it so it can access all of their information (status, for example) and perform operations over all its members (interrupt, for example).

Check out how one of the thread objects threw the exception that interrupted the other objects:

When an uncaught exception is thrown in a Thread object, the JVM looks for three possible handlers for this exception.

First, it looks for the uncaught exception handler of the thread, as explained in the Processing uncontrolled exceptions in a thread recipe. If this handler doesn't exist, then the JVM looks for the uncaught exception handler of the ThreadGroup class of the thread, as learned in this recipe. If this method doesn't exist, the JVM looks for the default uncaught exception handler, as explained in the Processing uncontrolled exceptions in a thread recipe.

If none of the handlers exists, the JVM writes the stack trace of the exception in the console and ends the execution of the thread that had thrown the exception.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.149.253