12 线程池原理
12.1 为什么要使用线程池
12.2 线程池的原理
12.2.1 ThreadPoolExecutor提供的构造方法
// 五个参数的构造函数
public ThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue)
// 六个参数的构造函数-1
public ThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory)
// 六个参数的构造函数-2
public ThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
RejectedExecutionHandler handler)
// 七个参数的构造函数
public ThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory,
RejectedExecutionHandler handler)12.2.2 ThreadPoolExecutor的策略
12.2.3 线程池主要的任务处理流程

12.2.4 ThreadPoolExecutor如何做到线程复用的?
12.3 四种常见的线程池
12.3.1 newCachedThreadPool
12.3.2 newFixedThreadPool
12.3.3 newSingleThreadExecutor
12.3.4 newScheduledThreadPool
Last updated
Was this helpful?