Created
February 17, 2014 13:55
-
-
Save davidallsopp/9050955 to your computer and use it in GitHub Desktop.
Handling otherwise-unhandled exceptions in a thread. See the javadoc for Thread.setUncaughtExceptionHandler(): "Set the handler invoked when this thread abruptly terminates due to an uncaught exception. A thread can take full control of how it responds to uncaught exceptions by having its uncaught exception handler explicitly set. If no such han…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thread t = new Thread() { | |
public void run() { | |
// do something useful | |
} | |
}; | |
t.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { | |
public void uncaughtException(Thread exThread, Throwable ex) { | |
// handle it here | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment