首页  

java Virtual Threads 虚拟线程     所属分类 java 浏览量 747
JEP 425: Virtual Threads (Preview)
https://openjdk.java.net/jeps/425

虚拟线程 协程 轻量级线程
用户态线程  green threads

Preserving the thread-per-request style with virtual threads


Virtual threads are cheap and plentiful, and thus should never be pooled
A new virtual thread should be created for every application task.


every instance of java.lang.Thread in the JDK is a platform thread.

The number of platform threads is limited to the number of OS threads.

many virtual threads can run their Java code on the same OS thread, effectively sharing it

The number of virtual threads can be much larger than the number of OS threads.

Virtual threads are a lightweight implementation of threads that is provided by the JDK rather than the OS.

virtual threads vs. platform threads


Do not pool virtual threads

Thread pools, like all resource pools, are intended to share expensive resources, 
but virtual threads are not expensive and there is never a need to pool them.


平台线程由操作系统调度,虚拟线程由 JDK 运行时调度
内部使用ForkJoinPool 虚拟线程调度的专用池

上一篇     下一篇
temporal 工作流注册关键代码

PostgreSQL encode 函数

MySQL jdbc 版本问题导致 连接错误

GO gc 要点

git的几个实用命令

networking io with virtual threads