Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

As the technical leader of a large Java organisation in the virtual-thread era, what would you standardise or forbid to avoid the mistakes of the thread-pool era?

I would forbid pooling virtual threads and require one per task; require an explicit concurrency limit for every shared resource instead of relying on pool sizes; forbid ThreadLocal as a per-thread object cache and prefer scoped values for context where possible; set a minimum JDK of 24 or later, in practice Java 25, so synchronized does not pin; and update observability for the new thread dump format, JFR events and downstream saturation metrics. Each rule replaces a habit from the thread-pool era that silently did a job virtual threads no longer do.

Background to this question

For twenty years, Java teams learned to manage concurrency through thread pools. Pool sizes limited database load, pooled threads made ThreadLocal caches cheap, and pool utilisation was the first metric anyone checked during an incident. Virtual threads remove the pools, and with them all those side effects. A technical leader's job is to make sure the organisation does not carry the old habits into the new model, where they turn into outages. In this answer, we will recap what changes with virtual threads, then go through each standard: what it forbids or requires, which thread-pool habit it replaces, and how to enforce it.

1A Quick Recap of What Changed

A platform thread is an operating system thread, so it is expensive and we keep a few hundred in pools that tasks share. A virtual thread is managed by the JVM, costs a few hundred bytes to a few kilobytes while waiting, and is meant to be created for each task and thrown away. The JVM runs virtual threads on a small set of carrier threads, one per core by default, and unmounts them when they block.

So the unit we used to control, the pool, is no longer in the picture. Anything that depended on its size or its reuse of threads needs a new home. Each standard below is one of those homes.

2Standard 1: Never Pool Virtual Threads

Putting virtual threads in a fixed pool brings back the limit we wanted to remove and adds nothing: creating a virtual thread is cheaper than handing a task to a pool. So code creates them per task, through Executors.newVirtualThreadPerTaskExecutor(), Thread.ofVirtual() or framework support such as spring.threads.virtual.enabled.

Java
// forbidden: caps concurrency at 50 and reuses threads
ExecutorService pool = Executors.newFixedThreadPool(50, Thread.ofVirtual().factory());
// required: one virtual thread per task
try (ExecutorService exec = Executors.newVirtualThreadPerTaskExecutor()) {
tasks.forEach(t -> exec.submit(t));
}

Enforcement is easy and should be automatic: an architecture or static analysis rule in the shared build flags any fixed or cached pool created with a virtual thread factory.

3Standard 2: An Explicit Limit for Every Shared Resource

In the pool era, a Tomcat pool of 200 threads quietly meant that at most 200 requests could hit the database at once. With virtual threads, that limit disappears and the first spike overloads the connection pool or a partner API. The rule is that every shared resource, each database, each downstream service, each rate-limited API, has a limit that is stated in code or configuration and sized from that resource's capacity: a semaphore, a bulkhead from a resilience library, or a properly sized connection pool with a short acquisition timeout. A limit should come with a behaviour when it is full, usually failing fast with a clear error rather than queueing without end.

We provide this as a small platform library, so teams write limits.forResource("payments-api").run(...) with a configured size and get metrics for free. Design reviews for new integrations ask one question: where is the limit, and what happens when it is reached?

4Standard 3: No ThreadLocal Caches; Scoped Values for Context

A common trick in pooled code was caching an expensive object, such as a formatter, a buffer or a parser, in a ThreadLocal so each of 200 pooled threads built it once. With a new virtual thread per task, the cache is built once per task and thrown away, which is slower than not caching, and with 100,000 threads it can use a lot of memory. So we forbid ThreadLocal as an object cache; immutable thread-safe objects such as DateTimeFormatter are shared as constants, and genuinely expensive objects go into a small explicit pool.

For request context, such as the user, tenant or trace id, we prefer ScopedValue, final in Java 25, where our own code controls the context. Its binding is immutable and ends with the call, so it cannot leak between requests. Frameworks and logging libraries that still need ThreadLocals keep them; the standard is about our code, not a purge of every ThreadLocal in the process.

5Standard 4: A Minimum JDK of 24 or Later

On JDK 21 to 23, a virtual thread that blocks inside a synchronized block or method pins its carrier: the carrier cannot run other virtual threads until the block exits. With only one carrier per core, a library that does network I/O under synchronized can stall a whole service. JDK 24 removed this for synchronized (JEP 491). Rather than auditing every library for synchronized I/O, we set a minimum: virtual threads only on JDK 24 or later, which in practice means Java 25, the current LTS release. Remaining pinning, mostly through native code, is visible in JFR and handled case by case.

6Standard 5: Observability for the New Model

Our runbooks say to take a thread dump with jstack and check pool utilisation. Neither works well now. jstack does not list unmounted virtual threads; jcmd <pid> Thread.dump_to_file, in text or JSON, does, and the tooling that parses dumps must understand it. JFR events such as jdk.VirtualThreadPinned and jdk.VirtualThreadSubmitFailed should be part of the standard recording. And because there is no pool to saturate, the early warning of overload must come from the resources behind it: pending connections, semaphore waits and rejections, and downstream latency. Every service exposes these with the same names, so dashboards and alerts work across the fleet.

Thread-pool habits and their replacements
Old habitWhat it silently didNew standard
Fixed pools of threadsLimited concurrencyVirtual thread per task; no pooling
Pool size as capacity planProtected databases and APIsExplicit limit per shared resource
ThreadLocal object cachesReused objects across tasksShared immutable objects or explicit pools
ThreadLocal request contextPassed context, leaked when not removedScopedValue where we control the code
Any JDK 17+Nothing; no virtual threadsJDK 24+ so synchronized does not pin
Pool utilisation alertsEarly warning of overloadDownstream saturation metrics, new dumps, JFR

7Follow-up questions

How do you enforce standards across many teams without slowing them down?

By putting them in the platform rather than in documents: the shared build carries the JDK version and the static checks, a starter library provides limits, scoped context and metrics with sensible defaults, and the service template already follows the rules. Written standards then explain the reasons, and exceptions go through a short review with an owner and an expiry date.

Would you forbid synchronized in new code?

No. On JDK 24 and later it no longer pins in the common cases, and for short critical sections it is simple and correct. What I would discourage is long blocking operations, such as I/O, inside any lock, synchronized or ReentrantLock, because that limits throughput regardless of the thread type.

What about CPU-bound work?

It stays on platform thread pools sized to the cores, and the standard says so explicitly. Virtual threads are for tasks that wait; a pool for computation is not a thread-pool-era mistake but the right tool.

8Conclusion

In this answer, we went through five standards for the virtual-thread era: never pool virtual threads and create one per task, put an explicit limit on every shared resource instead of relying on pool sizes, stop using ThreadLocal as an object cache and prefer scoped values for context, require JDK 24 or later so synchronized does not pin, and update observability with the new thread dump format, JFR events and downstream saturation metrics. Each one replaces a job the thread pool used to do silently, and each is enforced through the platform rather than by reminders.

What to say in the interviewAbout 90 seconds aloud

Open with

My starting point is that thread pools used to do several jobs silently, and when they disappear each job needs an explicit replacement. First, I would forbid pooling virtual threads.

Then, if they want more

They are cheap, so we create one per task, and a fixed pool of them just brings back the old cap; a static check in the shared build catches it.

Second, every shared resource, each database, downstream service or rate-limited API, gets an explicit limit sized from its capacity, like a semaphore or bulkhead with a short timeout and a clear failure, because the old 200-thread pool was secretly what protected the database. Third, no ThreadLocal used as a per-thread object cache.

With a new thread per task the cache never gets reused and can cost a lot of memory; we share immutable objects instead. For our own request context, like user or trace id, I prefer scoped values, which cannot leak between requests.

Fourth, a minimum JDK of 24 or later, in practice Java 25, because before that synchronized pins carriers and I do not want to audit every library.

Fifth, observability: the jcmd thread dump format that includes virtual threads, JFR pinning events in the standard recording, and saturation metrics on connection pools and downstream calls, since pool utilisation no longer warns us. All of it ships in the platform starter, so teams get it by default.

About this answer

Last updated
12 November 2026
Versions it names
Java 24, Java 25, Java 21
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 "As the technical leader of a large Java organisation in the virtual-thread era, what...": https://scrivio-interview-library.netlify.app/java/virtual-threads/d7ea7bb8d3/