public class DeathRattleExceptionHandler extends Object implements Thread.UncaughtExceptionHandler
final Counter c = Metrics.newCounter(MyRunnable.class, "thread-deaths");
Thread.UncaughtExceptionHandler exHandler = new DeathRattleExceptionHandler(c);
final Thread myThread = new Thread(myRunnable, "MyRunnable");
myThread.setUncaughtExceptionHandler(exHandler);
Setting the global default exception handler should be done first, like so:
final Counter c = Metrics.newCounter(MyMainClass.class, "unhandled-thread-deaths");
Thread.UncaughtExceptionHandler ohNoIDidntKnowAboutThis = new DeathRattleExceptionHandler(c);
Thread.setDefaultUncaughtExceptionHandler(ohNoIDidntKnowAboutThis);
Constructor and Description |
---|
DeathRattleExceptionHandler(Counter counter)
Creates a new
DeathRattleExceptionHandler with the given Counter . |
public DeathRattleExceptionHandler(Counter counter)
DeathRattleExceptionHandler
with the given Counter
.counter
- the Counter
which will be used to record the number of uncaught
exceptionspublic void uncaughtException(Thread t, Throwable e)
uncaughtException
in interface Thread.UncaughtExceptionHandler
Copyright © 2014. All Rights Reserved.