这一部分来说说线程池如何进行状态控制,即线程池的开启和关闭. 先来说说线程池的开启,这部分来看ThreadPoolExecutor构造方法: public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecut…
实现的接口:Executor, ExecutorService 子类:ScheduledThreadPoolExecutor 这类为java线程池的管理和创建,其中封装好的线程池模型在Executors类中有实现.抛开Executors类中的实现,仅谈线程池模型ThreadPoolExecutor 线程池设计原理分析:官方文档 Core and maximum pool sizes A ThreadPoolExecutor will automatically adjust the pool s…