![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
多线程
文章平均质量分 71
Pandada。
这个作者很懒,什么都没留下…
展开
-
ThreadLocal的实现原理
ThreadLocal的实现原理 ThreadLocal是用来保证对象被当前线程访问到的。 set方法 /** * Sets the current thread's copy of this thread-local variable * to the specified value. Most subclasses will have no need to * override this method, relying solely on the {@link #initialValue} *原创 2021-03-15 22:44:41 · 58 阅读 · 0 评论 -
线程池的五大实现
线程池的实现 五大实现 newFixedThreadPool:返回一个固定线程数的线程池 newSingleThreadExecutor:返回一个只有一个线程的线程池 newCachedThreadPool:返回一个可根据实际情况调整线程数量的线程池 newSingleThreadScheduledExecutor:返回一个ScheduledExecutorService对象,线程池大小为1。 newScheduledThreadPool:返回一个ScheduledExecutorService对象,线程原创 2021-03-15 15:40:17 · 119 阅读 · 0 评论 -
从线程工厂到线程
从线程工厂到线程 工厂模式中有四个角色: Factory:抽象的工厂 Product:抽象的零件 具体的实现工厂 具体的实现零件 上图就是一个工厂模式。 线程池是一个工厂,线程是线程池中的零件。 抽象工厂 public interface ThreadFactory { /** * Constructs a new {@code Thread}. Implementations may also initialize * priority, name, daemon s原创 2021-03-14 22:02:18 · 71 阅读 · 0 评论