Scrivio Interview library
ScenarioAdvanced6 min read · updated 12 November 2026

Your platform runs on Java 21, and leadership wants to enable virtual threads across 60 services. Would you require an upgrade to Java 25 first? Lay out the trade-offs.

For most of the 60 services, yes, I would make the move to Java 25 the first step. On Java 21, synchronized pinning in drivers and libraries can cause stalls under load, and auditing every dependency of 60 services is costly and never quite complete; Java 24 and later remove most of that risk, and Java 25 is an LTS release. Upgrading first means one more migration with its own risk, but it removes a class of hard-to-diagnose incidents. If some services must stay on 21, they should start only where dependencies are known to avoid pinning, with jdk.VirtualThreadPinned monitored, and either way the rollout goes per service with load tests and metrics.

Why this question is asked

Leadership wants a visible win, and virtual threads promise one: more throughput from the same hardware with a configuration change. The platform team has to decide whether the JDK version the fleet runs on makes that change safe. This is a judgement call with costs on both sides, and interviewers ask it to see whether we can lay out those costs honestly, give a recommendation, and offer a path that does not block everything on one decision. In this answer, we will recap what differs between Java 21 and 25 for virtual threads, estimate what each path costs for 60 services, compare them, and then describe the plan I would propose.

1What Differs Between Java 21 and Java 25

Virtual threads are final and fully supported in Java 21. The important difference is pinning. On Java 21, a virtual thread that blocks while inside a synchronized block or method cannot unmount, so it holds its carrier thread, and there are only about as many carriers as CPU cores. A JDBC driver, cache client or logging library that does I/O inside synchronized can therefore stall every virtual thread in a service under load, even though the CPU is idle. JEP 491, delivered in Java 24 and therefore included in Java 25, lets virtual threads hold monitors without pinning, which removes this risk for almost all libraries without changing them.

Java 25 is also a long-term support release, so a fleet that moves there gets years of updates, plus other improvements such as final scoped values. The question is therefore not whether Java 25 is better for virtual threads, which it clearly is, but whether the upgrade should come first.

2The Cost of Staying on Java 21

Staying on 21 means every service's dependencies on the request path must be checked for pinning before virtual threads are enabled there. Sixty services might use a few hundred distinct libraries and versions, and pinning is not visible in code review of our own code; it hides inside drivers and clients, sometimes in a rarely used path. Static review cannot be complete, so the audit has to be confirmed by load testing each service with realistic slow dependencies, watching the JFR jdk.VirtualThreadPinned event.

The risk that remains after the audit is the expensive kind: an incident under real load where throughput collapses, the CPU is idle, and the cause is a library several layers down. Those incidents are hard to diagnose the first time, and with 60 services we should expect a few. Each library fix, such as upgrading a driver to one that uses ReentrantLock, also has to be tracked per service.

3The Cost of Upgrading First

Upgrading 60 services from Java 21 to Java 25 is a migration of its own. It means rebuilding images, updating build plugins and some libraries, running regression tests and watching for behaviour changes such as removed or deprecated APIs and different GC defaults. A JDK upgrade between LTS releases is usually routine for services on current frameworks, Spring Boot 3.5 and 4.0 both support Java 25, but it still needs time and attention, and it delays the virtual-thread win by however long it takes.

The upside is that this migration is valuable even without virtual threads, because the fleet needs to move to the current LTS eventually, and it turns the virtual-thread rollout into a configuration change with much lower risk.

Two paths for 60 services
AspectEnable on Java 21Upgrade to 25 first
Time to first service on virtual threadsweeksafter the first services upgrade
Pinning in synchronizedreal risk, needs auditsremoved for almost all libraries
Per-service audit efforthigh: every dependencylow: ThreadLocal and pool sizing only
Incident risk under loadstalls that are hard to diagnoseordinary tuning issues
Other valuenonecurrent LTS, needed eventually
Migrations to manageone, with long auditstwo, each simpler

4What I Would Recommend

I would recommend upgrading to Java 25 first for the fleet, and presenting it to leadership as the fastest safe path rather than a delay. The JDK upgrade is work we owe anyway, it can start immediately, and each service that finishes it becomes eligible for virtual threads with a much lighter checklist. The two efforts then overlap: the first services can be on Java 25 with virtual threads within weeks, while the rest of the fleet upgrades behind them.

For any service that cannot upgrade soon, for example because of a dependency that does not yet support Java 25, I would allow virtual threads on Java 21 only under stricter conditions: its request-path dependencies are on versions known to avoid pinning, it passes a load test with slow dependencies, and jdk.VirtualThreadPinned events are monitored in production with an alert on long pinned waits.

5The Rollout, Either Way

Whichever JDK a service runs, the rollout is per service, not a fleet-wide switch. Each service enables virtual threads through configuration, spring.threads.virtual.enabled=true, so it can be turned off in minutes. Before enabling it in production, the service is load tested at realistic concurrency, with dependencies slowed down, comparing throughput and latency with the switch on and off. Its checklist covers more than pinning: ThreadLocal caches that multiply with concurrency, code that uses thread identity as a key, and downstream limits, since the thread pool no longer caps how many calls reach the database or other services. Metrics on connection pool waits, bulkhead rejections and latency are in place before the switch is flipped.

Starting with I/O-bound services with good observability gives early wins and teaches us what the checklist missed, before the harder services move.

Step throughEnabling virtual threads for one service
  1. Is the service on Java 25?
    YesLight checklistNoStrict checklist: pinning audit + JFR alerting
  2. Check ThreadLocal caches and thread identityper-thread caches, maps keyed by thread
  3. Add explicit downstream limitsconnection pools, semaphores, bulkheads
  4. Load test with switch on and offslow dependencies, realistic concurrency
  5. Enable in production behind the switchwatch pool waits, rejections, latency

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

6Follow-up questions

What if leadership insists on starting now on Java 21?

Then start with a small number of services whose dependencies are known to be safe, such as services that use a driver version already using ReentrantLock, with JFR pinned events monitored and the switch ready. That delivers an early result while the JDK upgrade proceeds, and the evidence from those services informs the rest.

Is Java 24 an option instead of 25?

Java 24 has JEP 491, but it is not an LTS release, so its updates end quickly. For a fleet of 60 services, going straight to the LTS avoids another upgrade soon after.

How do you measure success?

Per service: throughput at a fixed latency target, instance count for the same traffic, and incident count related to concurrency. A service that shows no gain, often a CPU-bound one, can simply leave the switch off.

7Conclusion

In this answer, we saw that the key difference between Java 21 and 25 for virtual threads is pinning in synchronized, which on 21 can stall a service under load and makes auditing every dependency of 60 services expensive and incomplete, while Java 24 and later remove most of that risk and Java 25 is the LTS. Upgrading first adds a migration but removes a class of hard incidents and is work owed anyway, so I would recommend it, overlapping the two efforts, with a stricter path for any service that must stay on 21. Either way, the rollout goes per service, behind a switch, with load tests and metrics.

What to say in the interviewAbout 90 seconds aloud

Open with

I'd recommend upgrading to Java 25 first for most services, and I'd present it as the fastest safe path, not a delay. The reason is pinning. On Java 21, any library that does I/O inside synchronized, typically a JDBC driver or a cache client, pins virtual threads to their carriers, and with only one carrier per core, a few slow calls can stall the whole service while the CPU sits idle.

Then, if they want more

Auditing that across 60 services means a few hundred libraries, it can't be complete from code review, and the failures show up as confusing incidents under real load. Java 24 removed most of that with JEP 491, and 25 is the LTS, so after the upgrade the checklist for virtual threads gets much lighter.

The upgrade itself is a migration with its own risk, rebuilding images, regression testing, some library bumps, but it's work we owe anyway, and it can overlap: the first services can be on 25 with virtual threads within weeks while the rest follow.

For any service stuck on 21, I'd allow virtual threads only with known-safe dependency versions, a load test with slow dependencies, and JFR pinned-event alerting. Either way, it goes per service behind spring.threads.virtual.enabled, with load tests, explicit downstream limits, and metrics on pool waits and latency.

About this answer

Last updated
12 November 2026
Versions it names
Java 25, Java 21, Java 24, Spring Boot 3.5
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 "Your platform runs on Java 21, and leadership wants to enable virtual threads across 60...": https://scrivio-interview-library.netlify.app/java/virtual-threads/1ebd1d35f5/