Scrivio Interview library
ConceptPrincipal6 min read · updated 12 November 2026

Virtual threads took years of JDK work before becoming final in Java 21, because blocking operations across many APIs had to be changed to unmount, and some pinning remained until JDK 24. What does this cost tell you, and how should you sequence a multi-year adoption?

The years of work show the cost of a deliberate choice: to keep existing blocking APIs working, the JDK changed their implementations from the inside rather than asking users to rewrite code, and limitations such as pinning in synchronized until JDK 24 show that adoption timing should follow the JDK's progress. I would sequence a multi-year adoption by readiness: move to a newer JDK first, then make sure key libraries avoid pinning and ThreadLocal caching problems, start with I/O-bound services that have good observability, expand from there, and keep a per-service switch so any service can roll back.

Why this question is asked

Virtual threads went through two preview releases, in JDK 19 and 20, before becoming final in JDK 21, and one of their most important limitations, pinning in synchronized code, was only removed in JDK 24 by JEP 491. For an organisation with dozens or hundreds of services, that history is not trivia; it is a guide to how and when to adopt. Interviewers at this level ask it to hear how we read a platform's trajectory and turn it into a plan. In this answer, we will look at why the work took so long, what the remaining limitations told us, and then lay out an adoption sequence with the reasoning for each stage.

1Why the Work Took Years

The goal of virtual threads was unusual: make existing, ordinary blocking code scale, without asking anyone to rewrite it in an asynchronous style. That meant every blocking operation in the JDK, socket reads and writes, sleeps, locks, queues, futures, selectors, DNS lookups, file operations and more, had to learn to park a virtual thread instead of blocking an OS thread. Each one had to be reimplemented inside the JDK while keeping its exact behaviour for platform threads, its error handling, its interrupt semantics and its performance.

Some of that work was large on its own. The socket implementation was rewritten in JDK 13 to make it suitable for virtual threads, years before virtual threads shipped. Debuggers, profilers, JFR and thread dumps had to understand a new kind of thread. And some pieces could not be done in time: the monitors behind synchronized were tied to OS threads deep in the JVM, so in JDK 21 blocking inside synchronized pinned the virtual thread to its carrier. Fixing that required changing how the JVM implements monitors, which arrived with JEP 491 in JDK 24.

The lesson is that the cost of compatibility is paid by the platform, over time. Users get to keep their code, but the guarantees arrive in stages, and an adopter must know which stage they are on.

How the capability arrived
ReleaseWhat changedWhat it meant for adopters
JDK 13socket implementation rewrittengroundwork, no virtual threads yet
JDK 19, 20virtual threads in previewexperiments only
JDK 21 (LTS)virtual threads finalusable, but synchronized pins
JDK 24JEP 491: synchronized no longer pins in most casesthe main pinning risk removed
JDK 25 (LTS)first LTS with JEP 491, scoped values finalthe natural production target

2What the Remaining Limitations Tell Us

On JDK 21, a JDBC driver, a cache client or a logging library that blocks inside synchronized can pin virtual threads. With only as many carriers as cores, a few slow calls pinned at once can stall every virtual thread in the service. Many libraries responded by replacing synchronized with ReentrantLock in their hot paths, but each one did so on its own schedule. So on JDK 21, adopting virtual threads safely meant auditing every dependency on the request path; on JDK 24 and later, most of that risk is gone.

There are other assumptions that no JDK release can fix, because they live in our code and libraries: per-thread caches in ThreadLocal or maps keyed by thread id, which multiply or leak when every task gets a new thread, and implicit concurrency limits that thread pools used to provide. These are readiness issues of the ecosystem, not of the JDK.

So the progress of the platform should set the pace. Moving faster than the JDK means paying for the gaps ourselves, in audits and incidents.

3Sequencing the Adoption

I would plan the adoption in stages, each with a clear exit condition. The first stage is the JDK itself: move services to a release where the main limitations are gone, which today means JDK 25, the first LTS with JEP 491. That upgrade is worth doing for its own reasons and removes the hardest-to-diagnose class of incidents before we start.

The second stage is library readiness. For the shared platform libraries, the database drivers, HTTP clients, connection pools, caches and logging, we check versions for pinning fixes and ThreadLocal or thread-identity caching, and record the minimum versions in the platform's dependency management, so every service inherits them.

The third stage is the first services. We pick I/O-bound services, those that spend most of their time waiting on databases and other services, because they gain the most, and we pick ones with good observability, so we can see pinning events, connection pool waits and latency clearly. Each one is load tested with virtual threads on and off, and only then enabled in production.

The fourth stage is expansion, in waves, using what the first services taught us, often as updates to the platform's default configuration rather than service-by-service work. CPU-bound services come last, or not at all, since they gain little.

Step throughAdoption stages
  1. Upgrade to a JDK with JEP 491JDK 25 LTS; worth doing on its own
  2. Set minimum library versionsdrivers, clients, pools, caches, logging
  3. Pilot I/O-bound, well-observed servicesload test with the switch on and off
  4. All criteria met in the pilot?no pinning stalls, pools sized, latency stable
    YesExpand in wavesNoFix findings, repeat the pilot
  5. Keep the per-service switchroll back any service in minutes

5 steps in order. Play them, or step through them one at a time.

4Keep a Per-Service Switch

Throughout, every service keeps a switch that turns virtual threads on or off without a code change. In Spring Boot, that is the property spring.threads.virtual.enabled, which can be set per environment. The switch matters because problems with virtual threads usually appear only under real load, such as a connection pool that becomes the bottleneck or a library that pins under a rare code path. With a switch, the response to such an incident is a configuration change and a restart, not an emergency release. It also makes the comparison honest: we can run the same build with the switch on and off and measure the difference.

5Follow-up questions

Should we wait for every library to be ready before starting?

No. Waiting for perfection delays the gains indefinitely. The point is to sequence: upgrade the JDK, fix the shared libraries that most services use, and start with the services whose dependencies are known to be ready. Remaining gaps are found in pilots, under a switch, where they are cheap.

What would you do on JDK 21 if an upgrade is years away?

Adopt more narrowly. Start with services whose dependencies are known to avoid pinning, watch jdk.VirtualThreadPinned events in JFR under load, and keep platform threads elsewhere. The audit cost is higher, so the scope should be smaller.

How do you measure whether the adoption is worth it?

Per service, compare throughput at a fixed latency target, and resource use, such as instances needed for the same traffic, with the switch on and off. For I/O-bound services the gains are usually clear; if a service shows none, there is no reason to keep it on.

6Conclusion

In this answer, we saw that virtual threads took years because the JDK chose to keep existing blocking APIs working by changing their implementations inside the platform, and that limitations such as pinning in synchronized until JDK 24 meant the guarantees arrived in stages. A multi-year adoption should follow that progress: upgrade to a JDK with JEP 491, set minimum library versions without pinning or thread-local caching problems, pilot I/O-bound services with good observability, expand in waves, and keep a per-service switch so every service can roll back.

What to say in the interviewAbout 80 seconds aloud

Open with

What the history tells me is that compatibility was paid for by the platform. The goal was that ordinary blocking code would scale without rewrites, so every blocking API in the JDK, sockets, sleeps, locks, queues, DNS and so on, had to be reimplemented to park a virtual thread instead of blocking the OS thread, plus debuggers, JFR and thread dumps had to learn about them.

Then, if they want more

That's why it went through previews in 19 and 20, became final in 21, and still pinned inside synchronized until JEP 491 in JDK 24. So the guarantees arrived in stages, and adoption should follow them rather than race ahead. My sequence would be: first, the JDK.

Move to 25, the first LTS with JEP 491, which is worth doing anyway and removes the hardest class of incidents. Second, libraries: set minimum versions for drivers, HTTP clients, pools, caches and logging that avoid pinning and thread-local caching, in the platform's dependency management so every service inherits them.

Third, pilot on I/O-bound services with good observability, load tested with virtual threads on and off. Then expand in waves, with CPU-bound services last or never. And throughout, every service keeps a switch, spring.threads.virtual.enabled in Spring Boot, so rollback is a config change, not a release.

About this answer

Last updated
12 November 2026
Versions it names
Java 24, Java 21, Java 13, Java 19
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
JEP 444, Virtual Threads
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Virtual threads took years of JDK work before becoming final in Java 21, because...": https://scrivio-interview-library.netlify.app/java/virtual-threads/dfa674c81d/