/** * Called by the Java Virtual Machine when a thread in this thread group stops because of an * uncaught exception. * * <p>The <code>uncaughtException</code> method of <code>ThreadGroup</code> does the following: * * <ul> * <li>If this thread group has a parent thread group, the <code>uncaughtException</code> method * of that parent is called with the same two arguments. * <li>Otherwise, this method determines if the <code>Throwable</code> argument is an instance * of <code>ThreadDeath</code>. If so, nothing special is done. Otherwise, the <code> * Throwable</code>'s <code>printStackTrace</code> method is called to print a stack * backtrace to the standard error stream. * </ul> * * <p>Applications can override this method in subclasses of <code>ThreadGroup</code> to provide * alternative handling of uncaught exceptions. * * @param t the thread that is about to exit. * @param e the uncaught exception. * @see java.lang.System#err * @see java.lang.ThreadDeath * @see java.lang.Throwable#printStackTrace(java.io.PrintStream) * @since JDK1.0 */ public void uncaughtException(Thread t, Throwable e) { if (parent != null) { parent.uncaughtException(t, e); } else if (!(e instanceof ThreadDeath)) { if (System.err != null) { /* can be null at startup */ e.printStackTrace(System.err); } } }