Я наткнулся на проблему, которую можно суммировать следующим образом:
Когда я создаю поток вручную (т.е. путем создания экземпляра java.lang.Thread), UncaughtExceptionHandler вызывается соответствующим образом. Однако, когда я использую ExecutorService с ThreadFactory, обработчик оммитирован. Что я пропустил?
public class ThreadStudy {
private static final int THREAD_POOL_SIZE = 1;
public static void main(String[] args) {
    // create uncaught exception handler
    final UncaughtExceptionHandler exceptionHandler = new UncaughtExceptionHandler() {
        @Override
        public void uncaughtException(Thread t, Throwable e) {
            synchronized (this) {
                System.err.println("Uncaught exception in thread '" + t.getName() + "': " + e.getMessage());
            }
        }
    };
    // create thread factory
    ThreadFactory threadFactory = new ThreadFactory() {
        @Override
        public Thread newThread(Runnable r) {
            // System.out.println("creating pooled thread");
            final Thread thread = new Thread(r);
            thread.setUncaughtExceptionHandler(exceptionHandler);
            return thread;
        }
    };
    // create Threadpool
    ExecutorService threadPool = Executors.newFixedThreadPool(THREAD_POOL_SIZE, threadFactory);
    // create Runnable
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            // System.out.println("A runnable runs...");
            throw new RuntimeException("Error in Runnable");
        }
    };
    // create Callable
    Callable<Integer> callable = new Callable<Integer>() {
        @Override
        public Integer call() throws Exception {
            // System.out.println("A callable runs...");
            throw new Exception("Error in Callable");
        }
    };
    // a) submitting Runnable to threadpool
    threadPool.submit(runnable);
    // b) submit Callable to threadpool
    threadPool.submit(callable);
    // c) create a thread for runnable manually
    final Thread thread_r = new Thread(runnable, "manually-created-thread");
    thread_r.setUncaughtExceptionHandler(exceptionHandler);
    thread_r.start();
    threadPool.shutdown();
    System.out.println("Done.");
}
}
Я ожидаю: три раза сообщение "Неотключить исключение..."
Я получаю: одно сообщение (вызванное созданным вручную потоком).
Воспроизводится с помощью Java 1.6 в Windows 7 и Mac OS X 10.5.
