Handling uncaught exceptions in unaccessible Java Thread

186 Views Asked by At

I'm using JavaSoundAudioIO in my project, which starts up a thread of its own. If it deems the chosen audio mixer unfit, it throws an UnsupportedArgumentException, which will then crash the program. How can I catch this Exception? I can't really attach an exception handler directly to that thread, as I don't have a reference to it. I tried using Thread.setDefaultUncaughtExceptionHandler from my main-thread, but that doesn't seem to do anything for the JavaSound-thread.

1

There are 1 best solutions below

0
user1854611 On

I just found out that the Eclipse debugger was catching the exception and stopping execution before it could get to the exception handler.. Deactivated this behaviour in Preferences>Java>Debug and Thread.setDefaultUncaughtExceptionHandler works as intended.