TPE:

java.util.concurrent.ThreadPoolExecutor
public ThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
@NotNull TimeUnit unit,
@NotNull BlockingQueue<Runnable> workQueue,
@NotNull ThreadFactory threadFactory,
@NotNull RejectedExecutionHandler handler)
Creates a new ThreadPoolExecutor with the given initial parameters.
Parameters:
corePoolSize - the number of threads to keep in the pool, even if they are idle, unless allowCoreThreadTimeOut is set
在池中保持的线程数,即使它们是空闲的,除非设置了allowCoreThreadTimeOut
maximumPoolSize - the maximum number of threads to allow in the pool
在池中允许的最大线程数
keepAliveTime - when the number of threads is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.
当线程数大于核心数时,这是多余空闲线程在终止前等待新任务的最大时间。
unit - the time unit for the keepAliveTime argument
时间单位的keepAliveTime参数
workQueue - the queue to use for holding tasks before they are executed. This queue will hold only the Runnable tasks submitted by the execute method.
队列用于在执行任务之前执行任务。此队列只保留执行方法提交的可运行任务。
threadFactory - the factory to use when the executor creates a new thread
在执行器创建新线程时使用的工厂
handler - the handler to use when execution is blocked because the thread bounds and queue capacities are reached
在执行被阻塞时使用的handler,因为到达了线程边界和队列容量
Throws:
IllegalArgumentException - if one of the following holds:
corePoolSize < 0
keepAliveTime < 0
maximumPoolSize <= 0
maximumPoolSize < corePoolSize
NullPointerException - if workQueue or threadFactory or handler is null allowCoreThreadTimeOut -- If false (default), core threads stay alive even when idle. If true, core threads use keepAliveTime to time out waiting for work
如果false(默认),核心线程即使在空闲时仍然存活。如果是true,核心线程使用keepAliveTime来等待工作
也就是说,如果allowCoreThreadTimeOut不改变(即:false), 则corePoolSize计数中的Thread即便是idle空闲的,也保持alive状态;
如果被设置成true了,此时keepAliveTime就派上用场了,

JDK:

ThreadPoolExecutor

public ThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory,
RejectedExecutionHandler handler)
用给定的初始参数创建新的 ThreadPoolExecutor。
参数:
corePoolSize - 池中所保存的线程数,包括空闲线程。
maximumPoolSize - 池中允许的最大线程数。
keepAliveTime - 当线程数大于核心时,此为终止前多余的空闲线程等待新任务的最长时间。
unit - keepAliveTime 参数的时间单位。
workQueue - 执行前用于保持任务的队列。此队列仅保持由 execute 方法提交的 Runnable 任务。
threadFactory - 执行程序创建新线程时使用的工厂。
handler - 由于超出线程范围和队列容量而使执行被阻塞时所使用的处理程序。
抛出:
IllegalArgumentException - 如果 corePoolSize 或 keepAliveTime 小于 0,或者 maximumPoolSize 小于等于 0,或者 corePoolSize 大于 maximumPoolSize。
NullPointerException - 如果 workQueue、 threadFactory 或 handler 为 null。

最新文章

  1. (转)Hibernate事务管理
  2. Unity中 动态加载 Resources.Load()和Asset Bundle 的区别
  3. 【转】“/usr/bin/ld: cannot find -lz”
  4. the apple tree
  5. ubuntu 下安装 cudnn
  6. ab性能测试工具的使用
  7. 小议SQL数据插入
  8. MongoDB 高可用集群副本集+分片搭建
  9. AI-序列化-做五个数据接口
  10. asp.net core 使用docker默认端口修改
  11. 2019.02.15 bzoj5210: 最大连通子块和(链分治+ddp)
  12. [USACO08DEC]Trick or Treat on the Farm 记忆化搜索
  13. 高通RFC适配RFFE-添加MIPI设备【转】
  14. dns over https 简单测试(docker 运行)
  15. WEB服务器与应用服务器解疑
  16. delphi中如何控制listview的每行的颜色
  17. HDU1506: Largest Rectangle in a Histogram(最大子矩阵,好题动态优化左右边界)
  18. Ajax-01 Ajax概述
  19. iOS 打开应用与系统功能的调用
  20. HDU-4738 Caocao's Bridges,注意重边不是桥!

热门文章

  1. javascript in IE
  2. Redis不重启的情况下 切换持久化模式
  3. JAVA Schedule的Cron表达式
  4. CTSC2010
  5. go http爬虫
  6. beego路由
  7. PHP SPL标准库-迭代器
  8. 第十四章 nginx代理配置
  9. Java实现:抛开jieba等工具,写HMM+维特比算法进行词性标注
  10. Spring Boot入门之Hello World