【并发编程】ThreadPoolExecutor参数详解
- ThreadPoolExecutor executor = new ThreadPoolExecutor(
- int corePoolSize,
- int maximumPoolSize,
- long keepAliveTime,
- TimeUnit unit,
- BlockingQueue<Runnable> workQueue);
Core pool size
The lower limit of threads that are contained in the thread pool. Actually, the thread
pool starts with zero threads, but once the core pool size is reached, the number of
threads does not fall below this lower limit. If a task is added to the queue when the
number of worker threads in the pool is lower than the core pool size, a new thread
will be created even if there are idle threads waiting for tasks. Once the number of
worker threads is equal to or higher than the core pool size, new worker threads
are only created if the queue is full—i.e., queuing gets precedence over thread cre‐
ation.
Maximum pool size
The maximum number of threads that can be executed concurrently. Tasks that are
added to the queue when the maximum pool size is reached will wait in the queue
until there is an idle thread available to process the task.
Maximum idle time (keep-alive time)
Idle threads are kept alive in the thread pool to be prepared for incoming tasks to
process, but if the alive time is set, the system can reclaim noncore pool threads.
The alive time is configured in TimeUnits , the unit the time is measured in.
Task queue type
An implementation of BlockingQueue that holds
tasks added by the consumer until they can be processed by a worker thread. De‐
pending on the requirements, the queuing policy can vary.
【并发编程】ThreadPoolExecutor参数详解的更多相关文章
- Java 并发编程 | 线程池详解
原文: https://chenmingyu.top/concurrent-threadpool/ 线程池 线程池用来处理异步任务或者并发执行的任务 优点: 重复利用已创建的线程,减少创建和销毁线程造 ...
- 并发编程——IO模型详解
我是一个Python技术小白,对于我而言,多任务处理一般就借助于多进程以及多线程的方式,在多任务处理中如果涉及到IO操作,则会接触到同步.异步.阻塞.非阻塞等相关概念,当然也是并发编程的基础. ...
- Android并发编程之白话文详解Future,FutureTask和Callable
从最简单的说起Thread和Runnable 说到并发编程,就一定是多个线程并发执行任务.那么并发编程的基础是什么呢?没错那就是Thread了.一个Thread可以执行一个Runnable类型的对象. ...
- 从缓存入门到并发编程三要素详解 Java中 volatile 、final 等关键字解析案例
引入高速缓存概念 在计算机在执行程序时,以指令为单位来执行,每条指令都是在CPU中执行的,而执行指令过程中,势必涉及到数据的读取和写入. 由于程序运行过程中的临时数据是存放在主存(物理内存)当中的,这 ...
- ThreadPoolExecutor参数详解
ThreadPoolExecutor全部参数的构造函数 public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long ke ...
- 并发编程 || Java线程详解
通用线程模型 在很多研发当中,实际应用是基于一个理论再进行优化的.所以,在了解JVM规范中的Java线程的生命周期之前,我们可以先了解通用的线程生命周期,这有助于我们后续对JVM线程生命周期的理解. ...
- java 并发编程lock使用详解
浅谈Synchronized: synchronized是Java的一个关键字,也就是Java语言内置的特性,如果一个代码块被synchronized修饰了,当一个线程获取了对应的锁,执行代码块时,其 ...
- shell编程系列23--shell操作数据库实战之mysql命令参数详解
shell编程系列23--shell操作数据库实战之mysql命令参数详解 mysql命令参数详解 -u 用户名 -p 用户密码 -h 服务器ip地址 -D 连接的数据库 -N 不输出列信息 -B 使 ...
- Java网络编程和NIO详解开篇:Java网络编程基础
Java网络编程和NIO详解开篇:Java网络编程基础 计算机网络编程基础 转自:https://mp.weixin.qq.com/s/XXMz5uAFSsPdg38bth2jAA 我们是幸运的,因为 ...
随机推荐
- ●CodeChef Sereja and Game
题链: https://www.codechef.com/problems/SEAGM题解: 概率dp,博弈论 详细题解:http://www.cnblogs.com/candy99/p/650434 ...
- ●BZOJ 1416 [NOI2006]神奇的口袋
题链: http://www.lydsy.com/JudgeOnline/problem.php?id=1416题解: Pòlya瓦罐模型: 给定罐子里每种颜色的球的个数A[i],按题目要求随机操作若 ...
- ●SPOJ 8222 NSUBSTR–Substrings
题链: http://www.spoj.com/problems/NSUBSTR/题解: 后缀自动机. 不难发现,对于自动机里面的一个状态s, 如果其允许的最大长度为maxs[s],其right集合的 ...
- 2015 多校联赛 ——HDU5294(最短路,最小切割)
Tricks Device Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) To ...
- 51Nod 1196 字符串的数量
用N个不同的字符(编号1 - N),组成一个字符串,有如下要求: (1) 对于编号为i的字符,如果2 * i > n,则该字符可以作为结尾字符.如果不作为结尾字符而是中间的字符,则该字符后面可以 ...
- bzoj 3673&3674: 可持久化并查集 by zky
Description n个集合 m个操作 操作: 1 a b 合并a,b所在集合 2 k 回到第k次操作之后的状态(查询算作操作) 3 a b 询问a,b是否属于同一集合,是则输出1否则输出0 0& ...
- Python Django系统
本节内容 路由系统,视图函数,模板引擎,ORM操作 FBV和CBV ORM操作补充 Cookie和Session Ajax入门 1. Django基本内容整理 1.1 路由系统 Django中路由系 ...
- Java线程池使用和常用参数
多线程问题: 1.java中为什么要使用多线程使用多线程,可以把一些大任务分解成多个小任务来执行,多个小任务之间互不影像,同时进行,这样,充分利用了cpu资源. 2.java中简单的实现多线程的方式 ...
- ubuntu查看IO
在命令行直接 cp 一个比较大的文件时,由于没有提示信息,总感觉很不放心,可以通过查看IO的方式确认cp操作的进展程度. 查看IO可以使用iostat命令,但是前提是要安装sysstat sudo a ...
- Docker使用 Supervisor 来管理进程
Docker 容器在启动的时候开启单个进程,比如,一个 ssh 或者 apache 的 daemon 服务.但我们经常需要在一个机器上开启多个服务,这可以有很多方法,最简单的就是把多个启动命令放到一个 ...