ThreadPoolExecutor 参数解释

ThreadPoolExecutor

参数名 作用
corePoolSize 核心线程池大小
maximumPoolSize 最大线程池大小
keepAliveTime 线程池中超过corePoolSize数目的空闲线程最大存活时间;可以allowCoreThreadTimeOut(true)使得核心线程有效时间
TimeUnit keepAliveTime时间单位
workQueue 阻塞任务队列
threadFactory 新建线程工厂
RejectedExecutionHandler 当提交任务数超过maxmumPoolSize+workQueue之和时,任务会交给RejectedExecutionHandler来处理
线程池执行流程图(来自美团技术团队)

 

 

ThreadPoolExecutor的运行状态有5种,分别为:

阻塞队列的成员:

JDK提供的四种已有拒绝策略,其特点如下:

posted @ 2021-11-19 15:28  木子李和三点水  阅读(464)  评论(0编辑  收藏  举报