Java Thread setDefaultUncaughtExceptionHandler() method

The setDefaultUncaughtExceptionHandler() method of thread class sets the default handler invoked when a thread abruptly terminates due to an uncaught exception, and no other handler has been defined for that thread.

Syntax

Parameter

eh: It is the object which is used as the default uncaught exception handler.

Return

This method does not return any value.

Exception

SecurityException: This exception throws if a security manager is present and it denies RuntimePermission.

Example

Test it Now

Output:

Exception caught: java.lang.RuntimeException





Latest Courses