/virtual-threads-quarkus

Quarkus demo application to compare controllers using platform threads, CompletableFuture, and virtual threads.

Primary LanguageJava

Virtual Threads Quarkus Demo

This repository contains a Quarkus demo application using "Virtual Threads", a feature described in JEP 444 and released in Java 21.

The application has three controllers:

  • ControllerEvolution1_Sequential: sequential code on platform threads
  • ControllerEvolution2_CompletableFuture: asynchronous code using CompletableFuture
  • ControllerEvolution3_VirtualThreads: sequential code on virtual threads

Start the application in dev mode using:

mvn quarkus:dev

Then query the endpoints using:

curl localhost:8080/stage1-seq/product/1
curl localhost:8080/stage2-cf/product/1
curl localhost:8080/stage3-vt/product/1

Within IntelliJ, you can also open the endpoints-test.http file to run the HTTP requests.

Java 21 IDE Support

IntelliJ IDEA supports Java 21 as of version 2023.2.2. As long as this version is not yet released, you can install the release candidate via the JetBrains Toolbox App by going into the IntelliJ IDEA settings and activating the "Early Access Program".

Java Downloads

You can download Java 21 from here: https://jdk.java.net/21/

To install multiple Java versions on Linux or macOS, I recommend using SDKMAN!

To install multiple Java versions on Windows, have a look at this tutorial: How to Change Java Versions in Windows

Other Java 21 Examples

You might also find these GitHub repositories interesting:

Virtual Threads:

Structured Concurrency:

Scoped Values:

Pattern Matching for Switch: