This static function Thread.getDefaultUncaughtExceptionHandler()
from the java.lang
package helps to return the default handler.
This exception will be raised only when a running thread abruptly dismisses due to an uncaught exception.
null
, there is no default.This method in the
Thread
class is purely used for exception handling purposes.
static Thread.UncaughtExceptionHandler
getDefaultUncaughtExceptionHandler()
The function doesn’t take any parameters.
The below-mentioned code helps to show the exception, null
, which means there is no default uncaught exception.
// Load Thread classimport java.lang.Thread;// Main classpublic class EdPresso implements Runnable {Thread thr;public EdPresso() {thr = new Thread(this);//calling run() functionthr.start();}// run() methodpublic void run() {// printing thread nameSystem.out.println("Thread is:" + thr.getName());/* returning the default handler that is invoked when a thread stops due to uncaught exception. */Thread.UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();System.out.println(handler);}public static void main(String[] args) {new EdPresso();}}