Java’s virtual threads, introduced as a preview feature in Java 19 and stabilized in Java 21, promise to revolutionize how we handle concurrent I/O operations. The marketing pitch is compelling: write thread-per-request code that scales to millions of concurrent operations without the memory overhead of platform threads.
We conducted extensive performance testing comparing virtual threads against traditional platform threads using a typical Spring Boot web application with database operations. Our findings reveal both the promise and the pitfalls of this new concurrency model.
We already did something similar in a previous article Spring Boot 3 with Java 19 Virtual Threads. Here we discovered that when introducing some “delay” in the connection between the database and the application, (which mimick more precisely a real production application) the performance of virtual threads had a huge dump due to synchronized code blocks present in various libraries.
In this article we will see if the promises of Java 24 JEP 491, which prevents virtual thread pinning, are really up to the expectations.