package threads; import java.lang.thread.uncaughtexceptionhandler; public class textexception { public static void main(string[] args) { test test = new test(); test.setuncaughtexceptionhandler(new uncaughtexceptionhandler() { public void uncaughtexception(thread t, throwable e) { system.out.println(t.getname() + " : " + e.getmessage()); // todo } }); } public static class test extends thread { public test() { } public void run() { throw new runtimeexception("just a test"); } } }
更多java多线程编程之捕获子线程异常示例。
