org.xnap.commons.util
Class RootThreadGroup
java.lang.Object
java.lang.ThreadGroup
org.xnap.commons.util.RootThreadGroup
- All Implemented Interfaces:
- Thread.UncaughtExceptionHandler
public class RootThreadGroup
- extends ThreadGroup
The root thread group. Used to handle all uncaught exceptions that
occur at any child thread of the group.
If you want to catch all uncaught exceptions in your application,
use the following code snippet:
public static void main(final String[] argv) {
RootThreadGroup tg = new RootThreadGroup("RootThreadGroup",
new ErrorHandler());
Thread mainRunner = new Thread(tg, "XNapMain") {
public void run() {
runMain(argv);
}
};
mainRunner.start();
}
public static void runMain(final String[] argv) {
// run the actual main code
}
Methods inherited from class java.lang.ThreadGroup |
activeCount, activeGroupCount, allowThreadSuspension, checkAccess, destroy, enumerate, enumerate, enumerate, enumerate, getMaxPriority, getName, getParent, interrupt, isDaemon, isDestroyed, list, parentOf, resume, setDaemon, setMaxPriority, stop, suspend, toString |
RootThreadGroup
public RootThreadGroup(String name,
UncaughtExceptionListener listener,
boolean installAsAWTExceptionHandler)
RootThreadGroup
public RootThreadGroup(String name,
UncaughtExceptionListener listener)
handle
public void handle(Throwable e)
- Invoked by the AWTEventQueue in case of an unhandled exception.
- Parameters:
e
- the uncaught exception- See Also:
installAsAWTExceptionHandler()
installAsAWTExceptionHandler
public void installAsAWTExceptionHandler()
- Installs this class as the awt exception handler.
uncaughtException
public void uncaughtException(Thread t,
Throwable e)
- Specified by:
uncaughtException
in interface Thread.UncaughtExceptionHandler
- Overrides:
uncaughtException
in class ThreadGroup
- See Also:
ThreadGroup.uncaughtException(java.lang.Thread,
java.lang.Throwable)
Copyright © 2004-2007 XNap Commons Team. All Rights Reserved.