![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
线程池
文章平均质量分 82
平平无奇程序辕
平平无奇程序辕
展开
-
手撕源码系列之AQS -- AbstractQueuedSychronizer
AQS -- AbstractQueuedSychronizer简介重点成员变量statehead 和 tailNode对象重点方法acquiretryAcquireacquireQueuedrelease 释放锁操作问题简介重点成员变量 /** * Head of the wait queue, lazily initialized. Except for * initialization, it is modified only via method setHead.原创 2021-04-03 22:28:55 · 119 阅读 · 2 评论 -
手撕源码系列之线程池 -- ScheduledThreadPoolExecutor(二)
ScheduledThreadPoolExecutor的具体实现任务添加任务执行重复性任务的执行任务的取消任务添加ScheduledThreadPoolExecutor对任务的添加提供了大量的方法。重写ThreadPoolExecutor// 执行任务commandpublic void execute(Runnable command) { schedule(command, 0, TimeUnit.NANOSECONDS);}重写AbstractExecutorService/原创 2021-03-10 15:51:41 · 132 阅读 · 0 评论 -
手撕源码系列之线程池 -- ScheduledThreadPoolExecutor(一)
ScheduledThreadPoolExecutor构造方法简介:ScheduledThreadPoolExecutor用于执行周期性或延时性的定时任务,它继承了ThreadPoolExecutor,在原有基础上实现的任务调度线程池,内部使用延时工作队列DelayedWorkQueue实现对任务的延时调度。构造方法简介: ScheduledThreadPoolExecutor类继承的是ThreadPoolExecutor。而且它的构造方法都是super调用父类方法。由构造方法可以得知,Sche原创 2021-03-10 15:13:18 · 140 阅读 · 0 评论 -
手撕源码系列之线程池 -- ThreadPoolExecutor(二)
ThreadPoolExecutor(二)ThreadPoolExecutor实现流程ThreadPoolExecutor中实现的具体方法execute方法addWorker方法runWorkerThreadPoolExecutor实现流程ThreadPoolExecutor中实现的具体方法execute方法简介:execute方法是线程池添加任务的核心方法,由方法内判断是添加还是执行拒绝策略 //ThreadPoolExecutor的核心方法 public void execute(原创 2021-02-26 09:49:54 · 68 阅读 · 0 评论 -
手撕源码系列之线程池 -- ThreadPoolExecutor(一)
简介:ThreadPoolExecutor是线程池类,可以通俗的将它理解为存放一定数量线程的一个线程集合。线程池允许若个线程同时运行,同时运行的线程数量就是线程池的容量;当添加的到线程池中的线程超过它的容量时,会有一部分线程阻塞等待。线程池会通过相应的调度策略和拒绝策略,对添加到线程池中的线程进行管理。 ThreadPoolExecutor参数详解workersctl的作用和线程池状态详解构造方法核心参数QUEUE 缓存队列:RejectedExecutionHandler 拒绝策略ThreadF原创 2021-02-25 16:10:06 · 134 阅读 · 0 评论