I use ThreadPoolTaskExecutor as thread pool, and want to set the UncaughtExceptionHandler for new threads created, but it has no related method to specify.

Comment From: HKMV

May I ask in which version this feature is supported?

Comment From: shollander

java.lang.Thread.UncaughtExceptionHandler has been around since Java 1.5. You need to set it on each thread created by the Executor. The way to do it would be to have the ThreadFactory configure it for each new thread - similar to the thread name prefix. See apache/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java for an example.

Comment From: snicoll

This doesn't look like a good fit, indeed. Thread has a default static method for that and can be fine tuned by thread group or the thread itself. These mechanisms should be used by configuring the ThreadFactory. See CustomizableThreadCreator for an helper class that could facilitate such configuration.