文章预览
一、 一个线程池中的线程异常了,那么线程池会怎么处理这个线程? 需要说明,本文的线程池都是java.util.concurrent.ExecutorService线程池,本文将围绕 验证 , 阅读源码 俩方面来解析这个问题。 二、代码验证 2.1 验证execute提交线程池中 2.1.1 测试代码: public class ThreadPoolExecutorDeadTest { public static void main(String[] args) throws InterruptedException { ExecutorService executorService = buildThreadPoolExecutor(); executorService.execute(() -> exeTask("execute")); executorService.execute(() -> exeTask("execute")); executorService.execute(() -> exeTask("execute-exception")); executorService.execute(() -> exeTask("execute")); executorService.execute(() -> exeTask("execute")); Thread.sleep(5000); System.out.println("再次执行任务======================="); executorService.execute(() -> exeTask("execute")); executorServi
………………………………