配置eclipse支持jdk21及体验虚拟线程

星期四, 2023-09-21 | Author: Lee | JAVA-and-J2EE | 2,073 views

jdk21支持了虚拟线程,又是长期版本,体验下感觉

当前为止还只有官方版本,其他AWS等还没有对应的JDK21版本

下载地址:

openjdk 21
https://jdk.java.net/21/
oracle jdk 21
https://www.oracle.com/java/technologies/downloads/#jdk21-windows
graalvm-community-jdk-21.0.0_windows-x64_bin.zip
https://github.com/graalvm/graalvm-ce-builds/releases
graalvm-jdk-21_windows-x64_bin.zip
https://www.oracle.com/java/technologies/downloads/#graalvmjava21

eclipse下载最新:

Eclipse IDE 2023-09 R Packages
https://www.eclipse.org/downloads/packages/

eclipse更新支持插件:
Java 21 Support for Eclipse 2023-09 (4.29)

You can also install this feature from the following p2 update site directly:

https://download.eclipse.org/eclipse/updates/4.29-P-builds/

在install soft里使用上面地址加载编译支持jdk21可选

配置jdk21和编译支持如图

更新启动异步线程加载,以前使用5个异步线程,现在用虚拟线程替换,其他不用更改
代码片段:

ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();
@PostConstruct
public void init() {
 
       executor.submit(() -> {
			xxx();
       });
 
       executor.submit(() -> {
			xxx2();
			xxx3();
	});
	executor.submit(() -> {
			xx4();
			xx5();
	});
	executor.submit(() -> {
			xxx6();
			xxx7();
	});
}

启动 还比较流畅,应用使用了springboot3.1.3版本

Tags: ,

文章作者: Lee

本文地址: https://www.pomelolee.com/2408.html

除非注明,Pomelo Lee文章均为原创,转载请以链接形式标明本文地址

No comments yet.

Leave a comment

Search

文章分类

Links

Meta