Logic Foundry

Build with understanding.

Virtual Threads After JDK 24: The Production Bottleneck Moves

Reported November 23, 2026.

JDK 24 removed a major obstacle to using Java virtual threads in blocking web services: JEP 491 lets a virtual thread unmount from its carrier thread while inside a synchronized block. That addresses the monitor-related carrier-thread starvation possible in JDK 21. It does not remove every form of pinning, or make downstream services capable of handling unlimited concurrency.

Virtual Threads After JDK 24: The Production Bottleneck Moves (1)

The article’s authors evaluated virtual threads in an I/O-heavy Spring Boot service and published a controlled benchmark to make those remaining risks visible. Their practical conclusion is to audit code that assumes threads are reused, then set explicit limits around shared resources before increasing request concurrency.

What the benchmark showed

The test used Spring Boot 3.4 on Eclipse Temurin 25.0.3, running on an AWS c7i.2xlarge host with 8 vCPUs and 15 GiB of RAM. It compared embedded Tomcat with a 200-thread platform-thread pool against Tomcat with virtual threads enabled. A 500-user load ran for 60 measured seconds after a 30-second ramp-up; an I/O-heavy endpoint called a WireMock service configured with a 300 ms delay. The JVM settings, dependencies and host were held constant for the ThreadLocal comparison.

Virtual Threads After JDK 24: The Production Bottleneck Moves (2)

In that endpoint, the authors measured 200 initializations of a ThreadLocal.withInitial() cache with platform threads, versus 443,267 with virtual threads—about 2,216 times as many. A pooled platform thread could reuse its cached object; a new virtual thread handling each request could not. The virtual-thread run still achieved higher throughput and lower p99 latency in this test, but its extra allocations appeared as greater GC activity. These are results for the specified synthetic workload, not a general throughput guarantee.

Virtual Threads After JDK 24: The Production Bottleneck Moves (3)

A separate JDBC test exposed a different limit. Both modes wrote through HikariCP to the same PostgreSQL instance, but the configured connection pools differed: 20 connections for platform threads and 50 for virtual threads. Both pools saturated, and both runs had a 37% error rate. Raising request concurrency had moved pressure onto the database connection pool rather than eliminated the bottleneck.

An adoption checklist for blocking services

  • Check the JDK and observe pinning. JEP 491 arrived in JDK 24 and is included in JDK 25 LTS. Native frames and some file I/O can still pin virtual threads. The authors recommend load testing with the JFR jdk.VirtualThreadPinned event enabled and retaining jcmd Thread.dump_to_file -format=json in the diagnostic runbook. The older -Djdk.tracePinnedThreads property was removed in JDK 24.
  • Audit ThreadLocal use. A ThreadLocal remains usable on a virtual thread, but a cache designed for long-lived pooled threads may be rebuilt for every request. Counting calls to initialValue() can reveal that failure mode. If an object genuinely needs reuse on a small set of threads, the authors suggest handling that work with a bounded platform-thread executor instead.
  • Separate request context from caches. JDK 25 finalized Scoped Values in JEP 506. They offer a structured way to bind application-owned request context and propagate it to children created through StructuredTaskScope, avoiding the InheritableThreadLocal propagation failure the authors encountered. Scoped Values do not, by themselves, turn a per-request object into a reusable per-thread cache. Code written against preview versions also needs checking: ScopedValue.orElse(null) is no longer allowed.
  • Bound each scarce resource. Connection pools, rate-limited APIs and file-descriptor budgets still need explicit concurrency controls. The article recommends permits, such as a semaphore at a constrained downstream resource, rather than relying on a servlet thread-pool size as an indirect limit. A semaphore limits concurrent access; it does not provide reactive backpressure.
Virtual Threads After JDK 24: The Production Bottleneck Moves (4)

For Spring applications, the choice of framework remains workload-specific. The spring.threads.virtual.enabled=true setting can affect Servlet request handling on Tomcat or Jetty, but it does not switch Netty-based Spring WebFlux requests onto virtual threads. Spring MVC with virtual threads may simplify a service that adopted WebFlux chiefly to scale blocking request-response I/O. Streaming, SSE, WebSocket and systems that need backpressure retain reasons to use WebFlux. The authors also caution that a move from R2DBC to JDBC should be measured against the service’s own workload rather than assumed to improve performance.

Finally, JDK 25’s Structured Concurrency API was still a preview feature under JEP 505 at the time of the report. Teams can evaluate it for request fan-out and cancellation, but should expect source-level changes across JDK releases until it is finalized. Virtual threads make waiting for I/O cheaper; they do not speed up CPU-bound work or a slow downstream dependency.