{ System.out.println("----------"); System.out.。thread|thread UncaughtExceptionHandler。" />

thread|thread UncaughtExceptionHandler

ThreadFactory threadFactory = new ThreadFactoryBuilder()
【thread|thread UncaughtExceptionHandler】.setNameFormat("httpclient-pool-%d")
.setDaemon(true)
.setUncaughtExceptionHandler((t, e)-> {
System.out.println("----------");
System.out.println(t.getName() +":"+ e.getMessage());
})
.build();
ExecutorService executorService = Executors.newFixedThreadPool(10, threadFactory);
executorService.submit() 时,setUncaughtExceptionHandler 无效,需要 future.get(); 的方式获得异常。
executorService.excute() 时,setUncaughtExceptionHandler 可以捕获异常。

    推荐阅读