Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Virtual Threads Spring Demo

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

The application has two controllers:

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

Start the application in dev mode using:

mvn spring-boot:run

Then query the endpoints using:

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

To switch to virtual threads, uncomment the two bean definitions in SpringVirtualThreadTestApplication.java, then access this endpoint again:

curl localhost:8080/stage1-seq/product/1

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


Other Java 21 Examples

You might also find these GitHub repositories interesting:

Virtual Threads:

Structured Concurrency:

Scoped Values:

Pattern Matching for Switch:


Additional Resources


Java Versions PDF Cheat Sheet

Stay up-to-date with the latest Java features with this free PDF Cheat Sheet!

Java Versions PDF Cheat Sheet Mockup

  • Avoid lengthy research with this concise overview of all Java versions from Java 10 to Java 26.
  • Discover the innovative features of each new Java version, summarized on a single page.
  • Impress your team with your up-to-date knowledge of the latest Java version.

👉 Download the free Java Versions PDF

(Hier geht's zur deutschen Version → Java-Versionen PDF)


The Big O Cheat Sheet

With this free 1-page PDF cheat sheet, you'll always have the 7 most important complexity classes at a glance.

Big O PDF Cheat Sheet Mockup

  • Always choose the most efficient data structures and thus increase the performance of your applications.
  • Be prepared for technical interviews and confidently present your algorithm knowledge.
  • Become a sought-after problem solver and be known for systematically tackling complex problems.

👉 Download the free Big O Cheat Sheet

(Hier geht's zur deutschen Version → O-Notation Cheat Sheet)


HappyCoders Newsletter

👉 Want to stay on top of modern Java? Sign up for the HappyCoders newsletter – Modern Java: new versions & features, performance, and JVM insights – once a month.

(Hier geht's zur deutschen Version → HappyCoders-Newsletter deutsch)


🇩🇪 An alle Java-Entwickler:innen, die durch fundierte Kenntnisse über Datenstrukturen besseren Code schreiben wollen

Trage dich jetzt unverbindlich auf die Warteliste von „Mastering Data Structures in Java“ ein, und erhalte das beste Angebot!

Mastering Data Structures Mockup

👉 Zur Warteliste

About

Spring demo application to compare controllers using CompletableFuture vs. virtual threads.

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages