[JUC-4]ThreadPoolExecutor源码分析
相关博文:
https://segmentfault.com/a/1190000008693801
https://www.jianshu.com/p/fa1eac9710c8
//构造器1 public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { this(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, Executors.defaultThreadFactory(), defaultHandler); } //构造器2 public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler) { this(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, Executors.defaultThreadFactory(), handler); } //构造器3 public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler); 构造器参数详解如下: corePoolSize:核心线程的数量; maximumPoolSize:最大的线程数量; keepAliveTime:当线程数量大于corePoolSize时,多余的线程的最大存活时间(如果空闲的话); unit:keepAliveTime的单位; workQueue:提交但尚未被执行的任务队列; threadFactory:线程工厂,用于创建线程; handler:拒绝策略,当任务提交不能被执行时的补救措施;