Introduction
Java 21, the newest long-term support (LTS) version, has been released on 19 September 2023. This version brings many improvements and enhancements to the Java platform, such as records, sealed classes, pattern matching, and text blocks. However, one of the most anticipated and revolutionary features of Java 21 is virtual threads. Virtual threads enable web applications to scale with near-optimal hardware utilization with minimal changes.
How virtual threads works?

With the release on 23 November 2023, Spring Boot 3.2 has fully supported virtual threads. All you need to do to enable virtual threads is adding a configuration flag spring.threads.virtual.enabled=true
Benchmarks
Some benchmarks in the community show a significant improvement in performance. The following image from the https://mariadb.com/resources/blog/benchmark-jdbc-connectors-and-java-21-virtual-threads/ is an example.
s
At NashTech, we have also upgraded Yet Another Shop https://github.com/nashtech-garage/yas, our open-source project to Java 21 and Spring Boot 3.2, enabled virtual thread successfully. Our benchmark shows that the throughput of application increases about 15%. We believe the number will be higher if we could have a more ideal benchmark setup environment.

Is it easy to upgrade to Java 21 and Spring Boot 3.2
From our experience, it is very easy if your applications use Java 17 and Spring Boot 3.x. For our YAS project, all we need to do is change the Java version to 21, Spring Boot version to 3.2.0. Be noted that Java 21 will require the latest Lombok version (1.18.30) and Spring Boot 3.2 only compatible with Spring Cloud 2023.x.x
Upgrading from Java 8, Java 11 or Spring Boot 2.x is a little trickier. Below are common issues we need to resolve:
- Spring Boot 3 removed package javax, replaced by Jakarta API
- WebSecurityConfigurerAdapter deprecated in Spring Security 5.7.0-M2 and moved towards a component-based security configuration.
- The lib usertype has not caught up with Hibernate 6. Remove it and replace joda.time by java.time