Exception handling in ThreadPools

I wrote a small post about this problem a while ago. You have two options:

  1. Use the solution provided by Colin Herbert or
  2. use a modified version of Mark Peters solution but instead of assigning a UncaughtExceptionHandler you wrap each submitted runnable into a runnable of your own which executes (calls run) the real runnable inside a try-catch-block.

EDIT
As pointed out by Mark, it’s important to wrap the Runnable passed to ScheduledExecutorService instead of the one passed to the ThreadFactory.

Leave a Comment