Executors
提供了工厂方法:
Factory and utility methods for Executor
, ExecutorService
, ScheduledExecutorService
, ThreadFactory
, and Callable
classes defined in this package. This class supports the following kinds of methods:
- Methods that create and return an
ExecutorService
set up with commonly useful configuration settings. - Methods that create and return a
ScheduledExecutorService
set up with commonly useful configuration settings. - Methods that create and return a "wrapped" ExecutorService, that disables reconfiguration by making implementation-specific methods inaccessible.
- Methods that create and return a
ThreadFactory
that sets newly created threads to a known state. - Methods that create and return a
Callable
out of other closure-like forms, so they can be used in execution methods requiringCallable。
1、ExecutorService (为ThreadPoolExecutor设置了一些通用的参数来生成一些线程池,使用的BlockingQueue都是inbound的queue)
1、ScheduledThreadPool
2、singledThreadPool(线程的顺序执行,使用该线程池,可以保证线程的顺序性,不会竞争资源)
3、cachedThreadPool(默认是线程处于idle 6s就自动回收,适合大量而且小的异步任务)
4、FixedThreadPool
Executors的更多相关文章
- 并发包的线程池第二篇--Executors的构造
上一篇讲述了ThreadPoolExecutor的执行过程,我们也能看出来一个很明显的问题:这个线程池的构造函数比较复杂,对于不十分理解其运作原理的程序员,自己构造它可能体现和想象中不一样的行为.比如 ...
- Java8并发教程:Threads和Executors
来之:ImportNew 欢迎阅读我的Java8并发教程的第一部分.这份指南将会以简单易懂的代码示例来教给你如何在Java8中进行并发编程.这是一系列教程中的第一部分.在接下来的15分钟,你将会学会如 ...
- java 多线程--- Thread Runnable Executors
java 实现多线程的整理: Thread实现多线程的两种方式: (1)继承 Thread类,同时重载 run 方法: class PrimeThread extends Thread { long ...
- 线程池ThreadPoolExecutor、Executors参数详解与源代码分析
欢迎探讨,如有错误敬请指正 如需转载,请注明出处 http://www.cnblogs.com/nullzx/ 1. ThreadPoolExecutor数据成员 Private final Atom ...
- Java并发编程核心方法与框架-Executors的使用
合理利用线程池能够带来三个好处 降低资源消耗.通过重复利用已创建的线程降低线程创建和销毁造成的消耗. 提高响应速度.当任务到达时,任务可以不需要等到线程创建就能立即执行. 提高线程的可管理性.线程是稀 ...
- jdk 1.8 Executors
Class Executors java.lang.Object java.util.concurrent.Executors public class Executors extends Objec ...
- Effective Java 68 Prefer executors and tasks to threads
Principle The general mechanism for executing tasks is the executor service. If you think in terms o ...
- Java 并发:Executors 和线程池
让我们开始来从入门了解一下 Java 的并发编程. 本文主要介绍如何开始创建线程以及管理线程池,在 Java 语言中,一个最简单的线程如下代码所示: Runnable runnable = new R ...
- Java通过Executors提供四种线程池
http://cuisuqiang.iteye.com/blog/2019372 Java通过Executors提供四种线程池,分别为:newCachedThreadPool创建一个可缓存线程池,如果 ...
- java多线程之 Executors线程池管理
1. 类 Executors 此类中提供的一些方法有: 1.1 public static ExecutorService newCachedThreadPool() 创建一个可根据需要创建新线程的线 ...
随机推荐
- iOS开发遇到的坑之四--图片命名不规范
最近上手并主导一个小项目的研发,在开发地图模块的时候,UI切图给我们使用,他给的图片命名是1.1.1.png 1.1.2.png 1.1.3.png 我也没有多看,就直接打包发给小组成员叫他添加到Im ...
- 746. Min Cost Climbing Stairs@python
On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay ...
- Bzoj3170: [Tjoi2013]松鼠聚会 (切比雪夫距离)
题目链接 显然,题目要求我们求切比雪夫距离,不会的可以去看一下attack的博客. 考虑枚举所有的点 转换为曼哈顿距离后. 那么对于这个点的路程和是. \[\sum_{i=1}^n | x_i - x ...
- 如何用纯 CSS 创作一支诱人的冰棍
效果预览 在线演示 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/vrxzMw 可交互视频教 ...
- 【php】 布尔值判断
当转换为 boolean 时,以下值被认为是 FALSE: 布尔值 FALSE 本身 整型值 0(零) 浮点型值 0.0(零) 空字符串,以及字符串 "0" 不包括任何元素的数组 ...
- css 元素垂直居中
通用 <div id="parent"> <div id="child">Content here</div> </d ...
- [转]pickle python数据存储
python的pickle模块实现了基本的数据序列和反序列化.通过pickle模块的序列化操作我们能够将程序中运行的对象信息保存到文件中去,永久存储:通过pickle模块的反序列化操作,我们能够从文件 ...
- [uiautomator篇] 找父亲节点和其他兄弟节点
https://testerhome.com/topics/1250 Appium [已解决] UiSelector 如何根据节点定位到父节点 / 兄弟节点? liqing380 · 发布于 2014 ...
- 九度oj 题目1340:小A的计算器
题目描述: 以往的操作系统内部的数据表示都是二进制方式,小A新写了一个操作系统,系统内部的数据表示为26进制,其中0-25分别由a-z表示. 现在小A要在这个操作系统上实现一个计算器,这个计算器要能实 ...
- mac上安装ruby
(转:http://www.cnblogs.com/daguo/p/4097263.html) 以下代码区域,带有 $ 打头的表示需要在控制台(终端)下面执行(不包括 $ 符号) 步骤0 - 安装系统 ...