Skip to content

Commit 9ce94d0

Browse files
committed
Simplify virtual threads guide by pushing users to 21
There are still a couple of mentions of Java 19 for the history of virtual threads but Java 21 is recommended everywhere else as, now that it is available, there is no point recommending Java 19 or documenting Java 19 usage.
1 parent ea5cab0 commit 9ce94d0

File tree

1 file changed

+8
-31
lines changed

1 file changed

+8
-31
lines changed

docs/src/main/asciidoc/virtual-threads.adoc

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ include::_attributes.adoc[]
1717
:topics: virtual-threads
1818
:extensions: io.quarkus:quarkus-core
1919

20-
This guide explains how to benefit from Java 19+ virtual threads in Quarkus application.
20+
This guide explains how to benefit from Java 21+ virtual threads in Quarkus application.
2121

2222
== What are virtual threads?
2323

@@ -40,7 +40,8 @@ It isn't a class distinct from link:{Thread}[Thread] or `VirtualThread` but rath
4040
=== Differences between virtual threads and platform threads
4141
We will give a brief overview of the topic here; please refer to the link:{vthreadjep}[JEP 425] for more information.
4242

43-
Virtual threads are a feature available since Java 19, aiming at providing a cheap alternative to platform threads for I/O-bound workloads.
43+
Virtual threads are a feature available since Java 19 (Java 21 is the first LTS version including virtual threads),
44+
aiming at providing a cheap alternative to platform threads for I/O-bound workloads.
4445

4546
Until now, platform threads were the concurrency unit of the JVM.
4647
They are a wrapper over OS structures.
@@ -165,7 +166,7 @@ Quarkus handles the creation of the virtual thread and the offloading.
165166
Since virtual threads are disposable entities, the fundamental idea of `@RunOnVirtualThread` is to offload the execution of an endpoint handler on a new virtual thread instead of running it on an event-loop or worker thread (in the case of RESTEasy Reactive).
166167

167168
To do so, it suffices to add the link:{runonvthread}[@RunOnVirtualThread] annotation to the endpoint.
168-
If the Java Virtual Machine used to **run** the application provides virtual thread support (so, Java 19 or later versions), then the endpoint execution is offloaded to a virtual thread.
169+
If the Java Virtual Machine used to **run** the application provides virtual thread support (so Java 21 or later versions), then the endpoint execution is offloaded to a virtual thread.
169170
It will then be possible to perform blocking operations without blocking the platform thread upon which the virtual thread is mounted.
170171

171172
In the case of RESTEasy Reactive, this annotation can only be used on endpoints annotated with link:{blockingannotation}[@Blocking] or
@@ -192,34 +193,17 @@ Add the following dependency to your build file:
192193
implementation("io.quarkus:quarkus-resteasy-reactive")
193194
----
194195

195-
Then, you also need to make sure that you are using the version 19+ of Java, this can be enforced in your pom.xml file with the following:
196+
Then, you also need to make sure that you are using Java 21+, this can be enforced in your pom.xml file with the following:
196197

197198
[source,xml,role="primary asciidoc-tabs-target-sync-cli asciidoc-tabs-target-sync-maven"]
198199
.pom.xml
199200
----
200201
<properties>
201-
<maven.compiler.source>19</maven.compiler.source>
202-
<maven.compiler.target>19</maven.compiler.target>
202+
<maven.compiler.source>21</maven.compiler.source>
203+
<maven.compiler.target>21</maven.compiler.target>
203204
</properties>
204205
----
205206

206-
Finally, until Java 21, you need to configure your compiler plugin with the `--enable-preview` flag.
207-
If you use Maven, make sure that the configuration of the Maven compiler plugin is the following:
208-
209-
[source, xml]
210-
----
211-
<plugin>
212-
<artifactId>maven-compiler-plugin</artifactId>
213-
<version>${compiler-plugin.version}</version>
214-
<configuration>
215-
<compilerArgs>
216-
<arg>--enable-preview</arg>
217-
<arg>-parameters</arg>
218-
</compilerArgs>
219-
</configuration>
220-
</plugin>
221-
----
222-
223207
==== Three development and execution models
224208

225209
The example below shows the differences between three endpoints, all of them querying a _fortune_ in the database then
@@ -382,14 +366,7 @@ mvn package
382366

383367
=== Using a local GraalVM installation
384368

385-
To compile a Quarkus applications leveraging `@RunOnVirtualThread` into native executable, you must be sure to use a GraalVM / Mandrel `native-image` supporting virtual threads, so providing at least Java 19+.
386-
387-
Then, until Java 21, you need to add the following property to your `application.properties` file:
388-
389-
[source, properties]
390-
----
391-
quarkus.native.additional-build-args=--enable-preview
392-
----
369+
To compile a Quarkus applications leveraging `@RunOnVirtualThread` into a native executable, you must be sure to use a GraalVM / Mandrel `native-image` supporting virtual threads, so providing at least Java 21.
393370

394371
Build the native executable as indicated on xref:./building-native-image.adoc[the native compilation guide].
395372
For example, with Maven, run:

0 commit comments

Comments
 (0)