Quick revision
The short answer
Each generation of Java's concurrency tools fixed a real pain of the one before: wait/notify was easy to get wrong, futures could not be composed, and CompletableFuture chains and reactive streams composed well but were hard to read, debug and profile. Structured concurrency, made practical by cheap virtual threads, returns to plain blocking code with lifetimes tied to scopes. The lesson is to choose abstractions that keep errors, cancellation and lifetimes explicit and visible to tools, to adopt new models in new code and in areas with real incidents rather than rewriting working code, and to invest in education and shared libraries.
What to remember
In this answer, we followed Java's waiting abstractions from wait/notify and join, to futures and latches, to CompletableFuture and reactive streams, to virtual threads and structured concurrency, and saw that each fixed a real pain and introduced a new cost. The lessons are to prefer abstractions that make errors, cancellation and lifetimes explicit, to favour code that debuggers and thread dumps can explain, to adopt new models in new code and where incidents justify it instead of rewriting working code, and to invest in education and shared libraries because concurrency bugs are so expensive.
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.
Each generation of Java's concurrency tools fixed a real pain of the one before: wait/notify was easy to get wrong, futures could not be composed, and CompletableFuture chains and reactive streams composed well but were hard to read, debug and profile. Structured concurrency, made practical by cheap virtual threads, returns to plain blocking code with lifetimes tied to scopes. The lesson is to choose abstractions that keep errors, cancellation and lifetimes explicit and visible to tools, to adopt new models in new code and in areas with real incidents rather than rewriting working code, and to invest in education and shared libraries.
Background to this question
A large Java codebase is usually a museum of concurrency styles. A module from 2008 uses wait and notify, a service from 2014 uses executors and latches, a 2018 rewrite uses CompletableFuture chains or Reactor, and new code may use virtual threads. Senior engineers are asked about this history because the choice of abstraction affects a codebase for ten years, and because every team will be tempted to rewrite everything in the newest style. In this answer, we will walk through each step of the history and the pain it fixed, then draw the lessons for choosing abstractions, and finish with how to adopt a new model without a rewrite.
1A Quick Walk Through the History
Java 1.0 gave every object a monitor, with wait, notify and join as the only ways to wait for another thread. They work, but every rule is manual: hold the lock, wait in a while loop, choose notify or notifyAll correctly, handle InterruptedException. A small mistake leads to lost wake-ups or stalls that are very hard to reproduce.
Java 5 brought java.util.concurrent: executors, Future, CountDownLatch, BlockingQueue and explicit locks. Waiting became a matter of calling future.get() or latch.await(), with timeouts and exceptions handled for us. The weakness was composition. A Future can only be waited on, so combining two results or reacting to completion meant blocking a thread just to wait.
Java 8 added CompletableFuture, and reactive libraries such as RxJava and Reactor became popular. Now we could compose asynchronous steps without blocking threads, which mattered when threads were expensive. The cost was readability and debuggability: business logic was split into lambdas, stack traces showed pool threads and framework internals instead of our call chain, exceptions travelled through special channels, and profilers could no longer say which request was slow.
Java 21 made virtual threads final, and structured concurrency is in preview. With cheap threads, blocking is no longer expensive, so we can write code in the plain sequential style again, and structured concurrency ties the lifetime of concurrent subtasks to a block of code.
| Generation | Fixed | Cost |
|---|---|---|
| wait/notify, join (1.0) | basic coordination | manual rules, lost signals, stalls |
| Futures, latches, executors (5) | timeouts, exceptions, thread reuse | no composition; blocking to combine |
CompletableFuture, reactive (8+) | composition without blocking threads | hard to read, debug and profile |
| Virtual threads, structured scopes (21+) | cheap blocking, scoped lifetimes | new; preview API still changing |
2What Structured Concurrency Gets Back
The idea of structured concurrency is borrowed from structured programming: just as a method call returns before the next line runs, concurrent subtasks started inside a block must finish before the block exits. If one fails, the others are cancelled, and the error appears where we started the work. Lifetimes become visible in the shape of the code.
This only became practical with virtual threads. When a thread cost 1 MB of native stack, forking a thread per subtask was wasteful, so we used asynchronous callbacks to avoid blocking. When a thread costs a few hundred bytes, we can afford one per subtask and simply block, and the code reads like the sequential version. Notice that this is a return to an older style, not a new invention: the industry moved away from blocking code because of thread cost, and came back once that cost disappeared.
3Lesson 1: Prefer Abstractions That Keep Errors, Cancellation and Lifetimes Explicit
Looking back, the incidents caused by each style have a common root. They happened where something important was implicit: an exception swallowed in a callback, a task that kept running after nobody wanted its result, a thread whose owner nobody knew. So the first question for any concurrency abstraction should be: when this goes wrong, where does the error appear, how does the work stop, and who owns its lifetime?
A good abstraction answers all three in the code itself. An executor with futures answers the error question. A scope answers all three. A fire-and-forget CompletableFuture chain answers none of them unless the team adds the discipline by hand.
4Lesson 2: Choose What the Tools Can See
The second lesson is about operating the system, not writing it. During an incident we rely on thread dumps, debuggers, profilers and tracing. Blocking code on threads, virtual or not, shows a stack trace that reads like our code: the handler called the service, which called the client, which is waiting on a socket. Reactive code at the same moment shows a pool thread in an event loop, and the request that is slow is nowhere on the stack.
So when two abstractions solve a problem equally well, we should prefer the one that our debugging and observability tools understand. That favours plain blocking code on virtual threads for most service code today, and keeps reactive streams for the cases where their strengths are needed, such as streaming data with back-pressure.
5Lesson 3: Adopt New Models Where They Pay, Not Everywhere
The history also shows how expensive rewrites are. Teams that rewrote stable services in reactive style around 2018 often gained little throughput, paid for months of work, and now face the question of rewriting back. Working concurrency code that has had years of production fixes contains knowledge that a rewrite throws away.
The rule I would set is simple: new code uses the current recommended model, and existing code is migrated only where it causes real incidents or blocks a needed change. That keeps the risk proportional to the benefit.
- Is the code causing incidents or slowing changes?YesPlan a migration with tests firstNoLeave it; document its model
- Is there a shared library for the new model?YesMigrate using itNoBuild or adopt one first
- Migrate one service, measure, then expand
3 steps in order. Play them, or step through them one at a time.
6Lesson 4: Invest in People and Shared Libraries
Concurrency bugs are among the most expensive bugs we have: they appear under load, often in production, and they are hard to reproduce. Every new abstraction is only as good as the team's understanding of it. So the real investment is education, covering what happens on failure, cancellation and shutdown, plus shared libraries that encode the right defaults, such as a helper that runs a fan-out with timeouts and cancellation, so each team does not reinvent it.
Shared libraries also protect us from API churn. Structured concurrency's API changed between preview releases; if a hundred services call it directly, every change is a hundred edits, while one internal helper changes once.
7Follow-up questions
Is reactive programming now obsolete?
No. Reactive streams still shine for streaming data with back-pressure, for example processing an unbounded event stream or proxying large responses, and in systems already built around a non-blocking stack. What changed is that we no longer need reactive code just to avoid blocking expensive threads, which was the main reason most teams adopted it.
How would you explain to a team why they should not rewrite their CompletableFuture code?
I would ask what problem the rewrite solves. If the code works, has tests and has no incidents, a rewrite costs time and adds new bugs for no user benefit. If the code is hard to change or hides failures, then we have a reason, and we migrate that part with tests in place, one service at a time.
What would you standardise across teams?
A small set of patterns: managed executors, virtual threads for blocking I/O, a fan-out helper with timeouts and fail-fast, rules for timeouts on every client, and guidance on when reactive streams are the right tool. Each pattern comes with an example and tests, owned by the platform team.
8Conclusion
In this answer, we followed Java's waiting abstractions from wait/notify and join, to futures and latches, to CompletableFuture and reactive streams, to virtual threads and structured concurrency, and saw that each fixed a real pain and introduced a new cost. The lessons are to prefer abstractions that make errors, cancellation and lifetimes explicit, to favour code that debuggers and thread dumps can explain, to adopt new models in new code and where incidents justify it instead of rewriting working code, and to invest in education and shared libraries because concurrency bugs are so expensive.
Open with
Each step in that history fixed a real problem. wait and notify worked but every rule was manual, so we got lost signals and stalls. Futures and latches gave us timeouts and exceptions, but you could not compose them without blocking a thread.
Then, if they want more
CompletableFuture and reactive streams composed nicely and avoided blocking expensive threads, but the code was hard to read, stack traces lost the request context, and profilers could not tell you which request was slow.
Virtual threads removed the cost of blocking, so structured concurrency can bring back plain sequential code where subtasks live inside a scope and fail and cancel together. The lesson I take is to choose abstractions that keep errors, cancellation and lifetimes explicit, and that our tools, thread dumps, debuggers and tracing, can show.
I would not rewrite working code just to follow the trend: new code uses the current model, and existing code moves only where it causes incidents or blocks changes, one service at a time with tests.
And I would invest in training and in a small shared library, for example a fan-out helper with timeouts, which also shields us from preview API changes.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 21, Java 5, Java 8
- 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 "Java's way of waiting for concurrent work moved from wait/notify and join, to...": https://scrivio-interview-library.netlify.app/java/threads/aa4ed5ca12/