Quick revision
The short answer
For request-response services, the standard I would set is plain blocking code on virtual threads, because it is the easiest to read, debug and test. Reactive code stays where streaming, backpressure or a large existing investment justifies it. CompletableFuture is for small fan-out cases, always with an explicit executor and a timeout. Structured concurrency is the future option for fan-out, but it is still a preview in Java 25, so we adopt it once it is final in our JDK. We document the choice per service type and migrate opportunistically, not all at once.
What to remember
In this answer, we saw that async styles spread because platform threads were expensive, and virtual threads have removed that reason for most request-response services. The standard makes blocking code on virtual threads the default, keeps reactive code for streaming, backpressure and existing investments, allows CompletableFuture for small fan-out with explicit executors and timeouts, and names structured concurrency as the target once it is final in our JDK. Documenting the choice per service type and migrating opportunistically, with load tests before each switch, lets teams adopt it without stopping feature work.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
For request-response services, the standard I would set is plain blocking code on virtual threads, because it is the easiest to read, debug and test. Reactive code stays where streaming, backpressure or a large existing investment justifies it. CompletableFuture is for small fan-out cases, always with an explicit executor and a timeout. Structured concurrency is the future option for fan-out, but it is still a preview in Java 25, so we adopt it once it is final in our JDK. We document the choice per service type and migrate opportunistically, not all at once.
Background to this question
When three concurrency styles coexist, the cost is not only in the code. Engineers moving between teams must learn a different model, shared libraries need three variants, and incidents take longer because nobody reads every style fluently. Java 21 and later change the trade-offs, because virtual threads remove the main reason most services went asynchronous. In this answer, we will see why the styles exist and what changed, define the standard with a reason for each part, show what each style looks like for the same task, and plan a migration that does not stop feature work.
1Why Three Styles Exist, and What Changed
Services adopted CompletableFuture and Reactor mainly because platform threads were expensive. Each thread reserves a large stack and is scheduled by the operating system, so a service with 5,000 requests in flight could not afford 5,000 blocked threads. Async styles let a few threads serve many requests by never blocking, at the cost of code split into callbacks or operator chains.
Virtual threads, final since Java 21, remove most of that cost. A virtual thread that blocks on a socket gives up its carrier thread, so blocking is cheap, and a service can run one virtual thread per request even with tens of thousands of requests in flight. For ordinary request-response services, the original reason for async code has largely gone. What remains are cases where the async style offers something else: streaming results, backpressure, or a codebase already built on it.
2The Same Task in Each Style
Here is one endpoint written three ways: load a user and their orders in parallel, with a 2-second limit.
All three work. The difference is in everything around them: the blocking version has ordinary stack traces, try and catch, and works with any debugger and profiler. The other two need their own error operators, context propagation and testing tools. For a team that writes mostly request-response code, the first version is the one everybody can maintain.
3The Standard, Part by Part
Plain blocking code on virtual threads is the default for new request-response services and new code in existing ones. The reason is readability and tooling: sequential code matches how engineers think, and it uses the stack traces, debuggers and thread dumps they already know. One caution belongs in the standard: before Java 24, blocking inside synchronized blocks could pin a virtual thread to its carrier, and since Java 24 that case is fixed, but native calls and some libraries can still pin, so teams should test their drivers and watch for pinning.
Reactive code stays where it earns its cost: streaming responses, such as server-sent events or large exports, flows that need backpressure, such as consuming a fast event stream into a slow sink, and services already built end to end on WebFlux, where a rewrite would cost more than it saves.
CompletableFuture is allowed for small fan-out inside otherwise blocking code, such as two to five parallel calls, with two firm rules: always an explicit executor, never the common pool for I/O, and always a timeout, on the client and as an orTimeout backstop. Structured concurrency is the intended replacement for that fan-out, but it is a preview in Java 25, so the standard names it as the target and asks teams to put fan-out behind a small shared helper, which we switch when it becomes final in the JDK we run.
| Service type | Default style | Notes |
|---|---|---|
| Request-response, CRUD, BFF | blocking on virtual threads | test drivers for pinning |
| Small fan-out inside a request | CompletableFuture via shared helper | explicit executor and timeout |
| Streaming, SSE, large exports | Reactor / WebFlux | backpressure is the reason |
| Existing reactive services | stay reactive | no rewrite without a business case |
| Future fan-out | structured concurrency | only once final in our JDK |
4Migrating Opportunistically
A standard that requires rewriting every service at once will be ignored or will stop feature work. So the rule is opportunistic. New services follow the standard. When a team substantially changes an existing endpoint, it moves that endpoint to the default style if the change is cheap. Reactive services that work well stay reactive. We do not measure success by how much old code was rewritten, but by whether new code follows the standard and whether incident time and onboarding time go down.
Before switching a service to virtual threads, the team runs a load test and compares throughput, p99 latency and pinning events with the old version. This catches drivers or libraries that behave badly on virtual threads before users do, and it gives the next team real numbers instead of opinions.
- Is it streaming or backpressure-heavy?YesKeep reactiveNoContinue
- Enable virtual threads in a branch
spring.threads.virtual.enabled=true on Boot 3.2+ - Load test: throughput, p99, pinningcompare with the current version
- Numbers as good or better?YesShip; rewrite endpoints as they changeNoInvestigate drivers and pinning first
4 steps in order. Play them, or step through them one at a time.
5Follow-up questions
Does Spring Boot support virtual threads out of the box?
Yes, since Spring Boot 3.2 the property spring.threads.virtual.enabled=true makes the embedded web server and several task executors use virtual threads. Check your version's documentation for exactly which components it covers.
Isn't reactive code still faster?
For pure throughput on I/O-bound request-response work, virtual threads usually come close enough that the difference rarely matters compared with readability. Reactive code can still win for streaming and backpressure, which is why the standard keeps it for those cases. Measure for your service rather than assuming.
What should a shared library expose under this standard?
Plain blocking methods as the primary API, since they work well on virtual threads, plus a CompletionStage variant for teams that compose futures, and a Reactor adapter only where reactive services need it. Timeouts and executors are handled inside the library.
6Conclusion
In this answer, we saw that async styles spread because platform threads were expensive, and virtual threads have removed that reason for most request-response services. The standard makes blocking code on virtual threads the default, keeps reactive code for streaming, backpressure and existing investments, allows CompletableFuture for small fan-out with explicit executors and timeouts, and names structured concurrency as the target once it is final in our JDK. Documenting the choice per service type and migrating opportunistically, with load tests before each switch, lets teams adopt it without stopping feature work.
Open with
I would start from why we have three styles: CompletableFuture and Reactor spread because platform threads were too expensive to block. Since Java 21, virtual threads make blocking cheap, so for most request-response services that reason has gone.
Then, if they want more
So my default would be plain blocking code on virtual threads. It reads like ordinary code, gives normal stack traces, and works with the debuggers, profilers and thread dumps everyone knows. I would keep reactive code where it really earns its cost: streaming, backpressure, or services already built end to end on WebFlux, where a rewrite is not worth it.
CompletableFuture stays for small fan-out inside a request, but always with an explicit executor and a timeout, ideally through a shared helper. Structured concurrency is where fan-out should end up, but it is still a preview in Java 25, so I would name it as the target and switch the helper once it is final in our JDK.
I would also mention pinning in the standard and ask teams to load test their drivers. Then I would document the choice per service type and migrate opportunistically: new services follow it, existing endpoints move when they are changed anyway, after a load test comparing throughput, p99 and pinning. No big-bang rewrite.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 21, Java 24, Java 25, Spring Boot 3.2
- 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
- java.util.concurrent, package documentation, JLS chapter 17, Threads and Locks
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 services mix CompletableFuture chains, Reactor pipelines and blocking code, and...": https://scrivio-interview-library.netlify.app/java/completable-future/b9f0266ae2/