Name

Thread.UncaughtExceptionHandler

Synopsis

This interface defines a handler to be invoked when a thread throws an exception that remains uncaught. When this happens, the uncaughtException( ) method of the registered handler is invoked with the Thread object that threw the exception and the Throwable exception object as arguments. The handler is run by the thread that received the exception, and that thread will exit as soon as the handler exits. If uncaughtException( ) itself throws an exception, that exception will be ignored.

An object that implements this interface may be registered for a Thread with the setUncaughtExceptionHandler( ) method. A default UncaughtExceptionHandler may be registered with the static method Thread.setDefaultUncaughtExceptionHandler( ) . If no handler or default handler is registered, the uncaughtException( ) method of the containing ThreadGroup is used instead.

public interface Thread.UncaughtExceptionHandler {
// Public Instance Methods
     void uncaughtException(Thread t, Throwable e);  
}

Implementations

ThreadGroup

Passed To

Thread.{setDefaultUncaughtExceptionHandler( ), setUncaughtExceptionHandler( )}

Returned By

Thread.{getDefaultUncaughtExceptionHandler( ), getUncaughtExceptionHandler( )}

Get Java in a Nutshell, 5th 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.