Jetty的threadpool模块
Jetty提供的线程池相关的模块,如下:
threadpoolthreadpool-virtual,使用JDK 21提供的virtual threads。threadpool-virtual-preview,使用JDK 19和JDK 20。
注意上述模块不能共存。
启用threadpool模块后再启用threadpool-virtual模块时,将会有类似如下的提示:
ERROR : Module threadpool-virtual provides threadpool, which is already provided by threadpool enabled in [${jetty.base}/start.d/threadpool.ini]
Usage: java -jar $JETTY_HOME/start.jar [options] [properties] [configs]
java -jar $JETTY_HOME/start.jar --help # for more information
threadpool
启用threadpool模块,执行如下命令:
java -jar $JETTY_HOME/start.jar --add-modules=threadpool
命令的输出,如下:
INFO : threadpool initialized in ${jetty.base}/start.d/threadpool.ini
INFO : Base directory was modified
threadpool模块的配置文件$JETTY_BASE/start.d/threadpool.ini,内容如下:
# ---------------------------------------
# Module: threadpool
# Enables and configures the Server ThreadPool.
# ---------------------------------------
--modules=threadpool
## Thread name prefix.
#jetty.threadPool.namePrefix=qtp<hashCode>
## Minimum number of pooled threads.
#jetty.threadPool.minThreads=10
## Maximum number of pooled threads.
#jetty.threadPool.maxThreads=200
## Number of reserved threads (-1 for heuristic).
#jetty.threadPool.reservedThreads=-1
## Whether to use virtual threads, if the runtime supports them.
## Deprecated, use Jetty module 'threadpool-virtual' instead.
#jetty.threadPool.useVirtualThreads=false
## Thread idle timeout (in milliseconds).
#jetty.threadPool.idleTimeout=60000
## The max number of idle threads that are evicted in one idleTimeout period.
#jetty.threadPool.maxEvictCount=1
## Whether to output a detailed dump.
#jetty.threadPool.detailedDump=false
各参数的说明,如下:
jetty.threadPool.namePrefix
线程池中各线程的名称前缀。jetty.threadPool.minThreads
线程池中线程的最小数量。jetty.threadPool.maxThreads
线程池中线程的最大数量。jetty.threadPool.reservedThreads
线程池中保留的线程的数量。jetty.threadPool.useVirtualThreads
不推荐使用。对于JDK 21,推荐使用threadpool-virtual模块。jetty.threadPool.idleTimeout
空闲线程从线程池中移除前等待的时长,单位:毫秒,默认值:60000,即60秒。jetty.threadPool.maxEvictCount
清理空闲线程时,单次操作中被移除掉的线程的数量。jetty.threadPool.detailedDump
是否导出线程池中各线程的完整的栈。默认值为false,即只输出栈顶。
threadpool-virtual
启用threadpool-virtual模块,执行如下命令:
java -jar $JETTY_HOME/start.jar --add-modules=threadpool-virtual
启用threadpool-virtual模块成功时的输出,如下:
INFO : threadpool-virtual initialized in ${jetty.base}/start.d/threadpool-virtual.ini
INFO : Base directory was modified
threadpool-virtual模块的配置文件$JETTY_BASE/start.d/threadpool-virtual.ini,内容如下:
# ---------------------------------------
# Module: threadpool-virtual
# Enables and configures the Server ThreadPool with support for virtual threads in Java 21 or later.
# ---------------------------------------
--modules=threadpool-virtual
## Platform threads name prefix.
#jetty.threadPool.namePrefix=qtp<hashCode>
## Minimum number of pooled threads.
#jetty.threadPool.minThreads=10
## Maximum number of pooled threads.
#jetty.threadPool.maxThreads=200
## Number of reserved threads (-1 for heuristic).
#jetty.threadPool.reservedThreads=-1
## Thread idle timeout (in milliseconds).
#jetty.threadPool.idleTimeout=60000
## The max number of idle threads that can be evicted in one idleTimeout period.
#jetty.threadPool.maxEvictCount=1
## Whether to output a detailed dump.
#jetty.threadPool.detailedDump=false
## Virtual threads name prefix.
#jetty.threadPool.virtual.namePrefix=qtp<hashCode>-virtual-
## Whether virtual threads inherits the values of inheritable thread locals.
#jetty.threadPool.virtual.inheritInheritableThreadLocals=true
各参数的说明,如下:
jetty.threadPool.namePrefix
同threadPool。jetty.threadPool.minThreads
同threadPool。jetty.threadPool.maxThreads
同threadPool。jetty.threadPool.reservedThreads
同threadPool。jetty.threadPool.idleTimeout
同threadPool。jetty.threadPool.maxEvictCount
同threadPool。jetty.threadPool.detailedDump
同threadPool。jetty.threadPool.virtual.namePrefix
virtual threads的线程名称的前缀。jetty.threadPool.virtual.inheritInheritableThreadLocals
是否复用ThreadLocal对象。默认值为true。
threadpool-virtual-preview
启用threadpool-virtual-preview模块,执行如下命令:
java -jar $JETTY_HOME/start.jar --add-modules=threadpool-virtual-preview
启用threadpool-virtual-preview模块成功时的输出,如下:
INFO : threadpool-virtual-preview initialized in ${jetty.base}/start.d/threadpool-virtual-preview.ini
INFO : Base directory was modified
threadpool-virtual-preview模块的配置文件$JETTY_BASE/start.d/threadpool-virtual-preview.ini,内容如下:
# ---------------------------------------
# Module: threadpool-virtual-preview
# Enables and configures the Server ThreadPool with support for virtual threads in Java 19 and Java 20.
# ---------------------------------------
--modules=threadpool-virtual-preview
## Platform threads name prefix.
#jetty.threadPool.namePrefix=qtp<hashCode>
## Minimum number of pooled threads.
#jetty.threadPool.minThreads=10
## Maximum number of pooled threads.
#jetty.threadPool.maxThreads=200
## Number of reserved threads (-1 for heuristic).
#jetty.threadPool.reservedThreads=-1
## Thread idle timeout (in milliseconds).
#jetty.threadPool.idleTimeout=60000
## The max number of idle threads that can be evicted in one idleTimeout period.
#jetty.threadPool.maxEvictCount=1
## Whether to output a detailed dump.
#jetty.threadPool.detailedDump=false
## Virtual threads name prefix.
#jetty.threadPool.virtual.namePrefix=qtp<hashCode>-virtual-
## Whether virtual threads are allowed to set thread locals.
#jetty.threadPool.virtual.allowSetThreadLocals=true
## Whether virtual threads inherits the values of inheritable thread locals.
#jetty.threadPool.virtual.inheritInheritableThreadLocals=true
各参数的说明,如下:
jetty.threadPool.namePrefix
同threadPool。jetty.threadPool.minThreads
同threadPool。jetty.threadPool.maxThreads
同threadPool。jetty.threadPool.reservedThreads
同threadPool。jetty.threadPool.idleTimeout
同threadPool。jetty.threadPool.maxEvictCount
同threadPool。jetty.threadPool.detailedDump
同threadPool。jetty.threadPool.virtual.namePrefix
virtual threads的线程名称的前缀。jetty.threadPool.virtual.allowSetThreadLocals
是否允许virtual threads记录ThreadLocal类型的对象。默认值为true。jetty.threadPool.virtual.inheritInheritableThreadLocals
是否复用ThreadLocal对象。默认值为true。
参考资料
Jetty的threadpool模块的更多相关文章
- python3 线程池-threadpool模块与concurrent.futures模块
多种方法实现 python 线程池 一. 既然多线程可以缩短程序运行时间,那么,是不是线程数量越多越好呢? 显然,并不是,每一个线程的从生成到消亡也是需要时间和资源的,太多的线程会占用过多的系统资源( ...
- Python之路(第四十六篇)多种方法实现python线程池(threadpool模块\multiprocessing.dummy模块\concurrent.futures模块)
一.线程池 很久(python2.6)之前python没有官方的线程池模块,只有第三方的threadpool模块, 之后再python2.6加入了multiprocessing.dummy 作为可以使 ...
- Jetty使用教程(四:21-22)—Jetty开发指南
二十一.嵌入式开发 21.1 Jetty嵌入式开发HelloWorld 本章节将提供一些教程,通过Jetty API快速开发嵌入式代码 21.1.1 下载Jetty的jar包 Jetty目前已经把所有 ...
- Jetty源码分析(一)
一.目的 1.了解jetty组成架构: 2.学习jetty启动过程: 3.学习请求访问过程: 4.学习jetty内各模块作用,学习各模块内部代码: 二.jetty版本 本文所学习的jetty版本为:9 ...
- Windows 上的 Jetty 小工具
做项目经常遇到需要开发Java应用,我喜欢用Jetty进行开发.部署,主要是由于Jetty的轻量级. Jetty 项目主页:http://www.eclipse.org/jetty/, 最新版9.30 ...
- Jetty应用服务器的安装详解
Jetty是一个开源的Servlet容器和应用服务器,它极度轻量级.高便携性.功能强大.灵活和扩展性好,而且支持各种技术如SPDY.WebSocket.OSGi.JMX.JNDI和JAAS.Jetty ...
- Jetty开发指导:HTTP Client
介绍 Jetty HTTP client模块提供易用的API.工具类和一个高性能.异步的实现来运行HTTP和HTTPS请求. Jetty HTTP client模块要求Java版本号1.7或者更高,J ...
- 45、concurrent.futures模块与协程
concurrent.futures —Launching parallel tasks concurrent.futures模块同时提供了进程池和线程池,它是将来的使用趋势,同样我们之前学习 ...
- 35、concurrent.futures模块与协程
concurrent.futures —Launching parallel tasks concurrent.futures模块同时提供了进程池和线程池,它是将来的使用趋势,同样我们之前学习 ...
- python线程池(threadpool)
一.安装 pip install threadpool 二.使用介绍 (1)引入threadpool模块 (2)定义线程函数 (3)创建线程 池threadpool.ThreadPool() (4)创 ...
随机推荐
- AI数字人SadTalker实战
1.概述 AI数字人在营销和品牌推广中扮演着至关重要的角色,许多企业和个人正积极利用数字技术来打造属于自己的财富.有没有一种简单而免费的方式来创建自己的数字人呢?本篇博客笔者将为大家介绍如何搭建属于自 ...
- 【LeetCode栈与队列#03】删除字符串中所有的相邻重复项
删除字符串中所有的相邻重复项 力扣题目链接(opens new window) 给出由小写字母组成的字符串 S,重复项删除操作会选择两个相邻且相同的字母,并删除它们. 在 S 上反复执行重复项删除操作 ...
- Java UML类图
在UML的静态机制中类图是一个重点,它不但是设计人员关心的核心,更是实现人员关注的核心.建模工具也主要根据类图来产生代码.类图在UML的9个图中占据了一个相当重要的地位.James Rumbaugh对 ...
- 摆脱鼠标系列 - vscode vim 插件 常用快捷键整理
列表 只总结当前用到的快捷键,并且对 ctrl+c v w 这三个快捷键还是用vscode,过渡下. 复制当前行 yy 复制当前单词 yaw 移动到下一个单词 w 下移10行 . 这个有不管用了,估计 ...
- be动词 系动词 连缀动词 Linking Verb
be动词 系动词 连缀动词 Linking Verb be 原型 am 第一人称单数形式 is 第三人称单数形式 are 第二人称单数和复数形式 been 过去分词 being 现在分词 was 第一 ...
- ESP8266 SPI 开发之软件驱动代码分析
一 基本概述 esp8266的SPI代码流程非常的清晰,主要有三部分构成: spi_init 配置 spi_trans 配置 data_transfer 配置这三块组成. 在这里,笔者就针对spi的这 ...
- js实现回调功能实例
所谓js回调,本人认为无非就是一个函数的参数是另外一个函数,而作为参数的函数就称之为回调函数 <script type="text/javascript"> //要请 ...
- UE虚幻引擎:生成云平台指定路径下的EXE文件
市面上大量优秀的游戏都是基于UE制作的,UE虚幻引擎制作的作品可以在windows.mac.linux以及ps4.x-boxone.ios.android甚至是html5等平台上运行.本文介绍了UE虚 ...
- python基础七(函数名称空间及作用域、函数对象、函数嵌套、闭包函数、装饰器)
一 名称空间(namespaces):存放名字的地方,是对栈区的划分. 有了名称空间之后,就可以在栈区中存放相同的名字,详细的名称空间.分三种1.1 内建名称空间存放的名字:存放的python解释器内 ...
- golang sync.Map之如何设计一个并发安全的读写结构?
在 golang中,想要并发安全的操作map,可以使用sync.Map结构,sync.Map 是一个适合读多写少的数据结构,今天我们来看看它的设计思想,来看看为什么说它适合读多写少的场景. 如下,是g ...