Visual Threads (虚拟线程)来了,终于可以把 8 换了。
1
Weixiao0725 2023-09-19 09:41:46 +08:00
21 是 LTS 吗
|
2
zhaojames077 2023-09-19 09:45:51 +08:00
是 Virtual Threads 吧
|
3
nikenidage1 2023-09-19 09:46:17 +08:00 14
他强任他强,清风拂山岗;他发由他发,我用爪哇八
|
4
Subfire 2023-09-19 09:46:28 +08:00
https://jdk.java.net/21/
21 General Availability 还不能下载吧? |
5
forschers OP 最大程度的提升硬件利用率
|
6
forschers OP @zhaojames077 我搞错了
|
7
8355 2023-09-19 09:48:26 +08:00
还是 java8 没用的 耶稣来了都改不了
|
8
banmuyutian 2023-09-19 09:48:29 +08:00
@Weixiao0725
应该是 |
10
forschers OP 好多年了
|
11
putaozhenhaochi 2023-09-19 09:50:25 +08:00 via iPhone
8 该换了吧
|
12
forschers OP @putaozhenhaochi 感觉可以换了 虚拟线程能大幅度提升硬件利用率
|
13
adonislau 2023-09-19 09:55:37 +08:00
不是 22 么?
|
14
chocotan 2023-09-19 09:56:10 +08:00
看下载地址,已经 GA 了,只是页面还没换
|
16
jamosLi 2023-09-19 09:56:34 +08:00 2
不打扰我用 1.8
|
17
chuck1in 2023-09-19 09:58:10 +08:00
21 是 lts 么。
|
18
mmdsun 2023-09-19 10:00:00 +08:00
@nikenidage1 之前看统计报告 java 8 现在用的人少了,还没 Java 11 多。
|
20
Subfire 2023-09-19 10:02:24 +08:00
@chocotan 为啥我这看的还是 Release-Candidate https://jdk.java.net/21/
|
21
Aresxue 2023-09-19 10:08:49 +08:00
生产还是 java8 ,太难升了,比如你依赖的单点登录的 client 是 1.8 吧不支持 11 你怎么推动别人改造
可以看看这篇 为什么很多公司选择不升级 JDK 版本,仍然使用 JDK8 ? - 君莫惘的回答 - 知乎 https://www.zhihu.com/question/325293339/answer/1150270157 |
22
zhouxelf 2023-09-19 10:09:15 +08:00 2
公司部分核心项目已经提前升级到 20 了,就等 21 出了
|
23
ychost 2023-09-19 10:42:23 +08:00
依赖的中间件都是 Netty + AIO 回调,这个 Loom 没法优化吧
|
25
zhouhu 2023-09-19 10:48:21 +08:00
分代 ZGC 据说性能很强
|
26
Goooooos 2023-09-19 10:49:47 +08:00
虚拟线程对于 ThreadLocal 有优化支持吗?
|
27
zhouhu 2023-09-19 10:50:37 +08:00
我看到油管的信息,分代 ZGC 吞吐量是 ZGC 的四倍,堆大小是 ZGC 的五分之一,很期待。
|
28
Mirage09 2023-09-19 10:51:12 +08:00 via iPhone
笑死 我们刚 migrate 到 11
|
30
zhouhu 2023-09-19 10:53:13 +08:00
@Goooooos https://openjdk.org/jeps/444
irtual threads support thread-local variables (ThreadLocal) and inheritable thread-local variables (InheritableThreadLocal), just like platform threads, so they can run existing code that uses thread locals. 没看到说有优化 |
32
coobbi 2023-09-19 11:16:07 +08:00
估计得明天,美国慢了 12 个小时
|
33
zhouhu 2023-09-19 11:18:19 +08:00
@Goooooos
JEP 446 Scoped Values (Preview) Introduce scoped values, values that may be safely and efficiently shared to methods without using method parameters. They are preferred to thread-local variables, especially when using large numbers of virtual threads. This is a preview API. |
34
neptuno 2023-09-19 11:39:30 +08:00
大概几点出来啊,好像没看到下载
|
35
GuardX 2023-09-19 11:51:31 +08:00
|
36
GuardX 2023-09-19 11:53:12 +08:00
没看到有 GA 版本呀
|
37
somebody 2023-09-19 13:33:56 +08:00 via Android
这篇文章可以再翻出来看看了:
甲骨文 Java 语言架构师:虚拟线程将会深刻影响大规模 Java 应用的并发机制 作者 | Brian Goetz ( Architect for the Java Language, Oracle Corporation ) https://mp.weixin.qq.com/s/mCMxVKjaaXhSHyGtMyn46g |
38
iblessyou 2023-09-19 13:55:29 +08:00
想用打包为 exe 的功能,得 jdk17 ,要下 vs ,搞了 2 小时没成功,继续玩 8……
|
39
giter 2023-09-19 13:55:47 +08:00
|
40
FallenTy 2023-09-19 14:04:01 +08:00
新项目有机会升,老项目继续祖宗之法。
|
41
bjfane 2023-09-19 14:05:32 +08:00
@iblessyou java 项目打包到“exe”,之前试过,这个 exe 和理解的 exe 不完全是一个东西,
比如加了类似“数据库连接池”(具体加什么都不能打忘记了),就没法打了, 总结就是算是语言行,但是不是所有项目都行,看用到了什么 |
42
leisifung 2023-09-19 14:09:57 +08:00
@Weixiao0725 是的。
|
43
eatgrass 2023-09-19 15:19:41 +08:00
继续玩 J8
|
44
just4id 2023-09-19 15:24:16 +08:00 via iPhone
转 Rust 了,不淌这浑水
|
46
natsu94 2023-09-19 16:07:41 +08:00
感谢 spring boot 3 ,我司主营业务已经升级到 17 了
|
47
Breadykid 2023-09-19 16:31:00 +08:00
虚拟线程是为了高吞吐,
并且习惯开一个线程池来操作的方式需要改为信号量操作,对已有功能升级还是需要代码改动的, 有高吞吐需求的新功能可以试试,在有栈协程中性能较优 https://openjdk.org/jeps/444 中有完整说明 |
49
lokig 2023-09-19 20:11:24 +08:00
这是一个大杀器,8 升级终于找到理由了。8 到 21 中间那些版本相比之下,就是小修小补
|
50
bjfane 2023-09-19 20:34:55 +08:00
|
51
suxixi 2023-09-19 20:40:05 +08:00
native 才是未来啊
|
52
lokig 2023-09-19 21:11:41 +08:00
oracle 官网已经可以下载了
https://www.oracle.com/java/technologies/downloads/ |
53
laojin 2023-09-19 21:47:37 +08:00
JDK 21 is the latest long-term support release of Java SE Platform.
|
54
QWE321ASD 2023-09-19 21:55:26 +08:00
一直有人说不好升级,排除中间件依赖的包改名或者移除的问题,模块化也没那么麻烦啊,更何况有类路径模式,即不创建 module-info 的用法,这种用法和用 jdk8 用着几乎没有区别
|
55
voidmnwzp 2023-09-19 23:08:38 +08:00 via iPhone
1.国内不会用 jdk8 以外的版本
2.同步原语没用协程重写,所以然并卵 |
56
fox0001 2023-09-19 23:14:42 +08:00 via Android
终于来了,但是要等各方面的跟进…
|
58
nnegier 2023-09-20 08:59:10 +08:00 via Android
java21 可以跑 java8 的字节码吗?
|
59
mmdsun 2023-09-20 09:30:09 +08:00 via iPhone
|
60
Subfire 2023-09-20 09:31:33 +08:00
终于 GA 了, https://jdk.java.net/21/
|
61
Aresxue 2023-09-20 10:11:29 +08:00
@mmdsun 真这么简单早升级完了,光 JPMS 和反射的限制就够喝一壶的,更别提原有的 java agent 可能都要失效了,我手上的项目 100 多个应用,2000 多个 pod ,要真到 21 没个两年下不来。
|
62
zhouhu 2023-09-20 10:34:30 +08:00
@voidmnwzp
你说的是这个吧 There are two scenarios in which a virtual thread cannot be unmounted during blocking operations because it is pinned to its carrier: When it executes code inside a synchronized block or method, or When it executes a native method or a foreign function. 官方解释: The scheduler does not compensate for pinning by expanding its parallelism. Instead, avoid frequent and long-lived pinning by revising synchronized blocks or methods that run frequently and guard potentially long I/O operations to use java.util.concurrent.locks.ReentrantLock instead. There is no need to replace synchronized blocks and methods that are used infrequently (e.g., only performed at startup) or that guard in-memory operations. As always, strive to keep locking policies simple and clear. 后续优化: In a future release we may be able to remove the first limitation above, namely pinning inside synchronized. The second limitation is required for proper interaction with native code. |
64
zhouhu 2023-09-20 12:24:03 +08:00 1
@arloor
some blocking operations in the JDK do not unmount the virtual thread, and thus block both its carrier and the underlying OS thread. If a virtual thread performs a blocking operation such as I/O or BlockingQueue.take() while it is pinned, then its carrier and the underlying OS thread are blocked for the duration of the operation. Frequent pinning for long durations can harm the scalability of an application by capturing carriers. |
65
Subfire 2023-09-20 16:23:12 +08:00
为啥换成 JDK21 后,
import java.util.concurrent.TimeUnit; 这个都报错 |
66
javaZhenJuan 2023-09-21 17:14:36 +08:00
@Subfire 我的也报错
|