Jul
11
11
I’ve recently spent some hours to track down a mysterious bug and I just couldn’t find it. Since my application is using a lot of Threads/Workers it came to my mind that a RuntimeException I did not catch could be the cause. I wrote a global handler for it and found where the problem was
Somewhere in main():
The class:
public class MyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
public void uncaughtException(Thread t, Throwable e) {
System.err.println (“Uncaught exception by “ + t + “:”);
e.printStackTrace();
}
}
public void uncaughtException(Thread t, Throwable e) {
System.err.println (“Uncaught exception by “ + t + “:”);
e.printStackTrace();
}
}
How to test it:
Related:
PermGen space exceptions with Maven due to memory leak
Drawing in Java
Selecting for write in a Java Selector
Are you interested in reading more from CodingClues?
Then subscribe to new postings
via RSS or
via
E-Mail.
Add New Comment
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks
(Trackback URL)