Java Data Type Tutorial - Java Thread .getUncaughtExceptionHandler ()








Syntax

Thread.getUncaughtExceptionHandler() has the following syntax.

public Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()

Example

In the following code shows how to use Thread.getUncaughtExceptionHandler() method.

class ThreadDemo extends Thread{
//from   ww  w  .j a  v a  2 s.  co m
  public void run() {
    System.out.println("Thread = " + getName());

    Thread.UncaughtExceptionHandler handler = getUncaughtExceptionHandler();
    System.out.println(handler);
  }

}

public class Main {

  public static void main(String[] args) {

    ThreadDemo t = new ThreadDemo();
    t.start();
  }

}

The code above generates the following result.