Java tutorial
public class Main { public static void main(String[] args) { Thread t = new Thread(new MyThread()); t.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { System.out.println(t + " throws exception: " + e); } }); t.start(); } } class MyThread implements Runnable { public void run() { throw new RuntimeException(); } }