Home > Software engineering >  What Happens when a thread doesn't throw an exception?
What Happens when a thread doesn't throw an exception?

Time:11-18

I notice, in this javadoc, https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.UncaughtExceptionHandler.html that an UncaughtExceptionHandler is used for when an exception occurs but is not caught. But, will that thread fail quietly? I guess so, because it is going about its business asynchronously, but I'm investigating a related issue with one of our processes, and am surprised at only being aware of this now, 10 years into my career.

CodePudding user response:

The thread will fail quietly :)

More than a decade ago a ran into a similar problem. The performance of a system started to degrade over time. Eventually, I identified the cause: an exception was thrown in a workerthread in some custom threadpool and the workerthread was terminated. So over time, the number of live threads in the threadpool started to decrease and performance dropped.

The problem was hidden by the fact that there was no logging of the exception.

  • Related