Quick revision
The short answer
My default policy is no preview features in production code, including structured concurrency in Java 25, because the API can change at every release and preview class files run only on the exact JDK that compiled them, which ties the service's upgrades to that code. I would let the team use it in experiments and internal tools, allow a production exception only with a named owner, isolation behind an interface and a plan for each release, and encourage the team to send its findings to OpenJDK.
What to remember
In this answer, we saw that structured concurrency is still a preview API in Java 25 and has already changed shape, and that preview class files run only on the JDK that compiled them, which blocks independent upgrades. The policy is no preview features in production by default, generous use in experiments and tools, a rare exception with an owner, isolation behind an interface and a review date, and active feedback to OpenJDK.
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.
My default policy is no preview features in production code, including structured concurrency in Java 25, because the API can change at every release and preview class files run only on the exact JDK that compiled them, which ties the service's upgrades to that code. I would let the team use it in experiments and internal tools, allow a production exception only with a named owner, isolation behind an interface and a plan for each release, and encourage the team to send its findings to OpenJDK.
Why this question is asked
Structured concurrency is attractive: it makes concurrent code with virtual threads read like sequential code and cancels sibling tasks automatically when one fails. So it is natural that a team wants it as soon as possible. Interviewers ask this as a leadership question because the right answer is a policy, not a yes or no, and it shows whether we can balance a team's enthusiasm against the cost to the platform. In this answer, we will recap what structured concurrency is and what preview means, look at the two concrete costs, set out the policy and the exception process, and show how to isolate the code if we grant an exception.
1A Quick Recap of Structured Concurrency and Preview Status
Structured concurrency treats a group of related tasks running in different threads as one unit of work. We open a scope, fork subtasks inside it, and join them before leaving the scope. If one subtask fails, the scope can cancel the others, and nothing outlives the block that started it. It pairs naturally with virtual threads, the lightweight threads delivered by Project Loom in Java 21.
In Java 25 it is still a preview API, now in its fifth preview (JEP 505). A preview API is complete but not permanent: we must compile and run with --enable-preview, and the API may change based on feedback before it becomes final.
Notice the open() factory and the joiner idea. Earlier previews, up to Java 24, used subclasses such as StructuredTaskScope.ShutdownOnFailure created with new. Code written against the Java 21 preview did not compile on Java 25. That is not a hypothetical risk; it already happened to this exact API.
2The Two Costs of Preview Code in Production
The first cost is churn. Because the API can change at every release, every JDK upgrade may require rewriting the code that uses it. The team that adopted it on 21 had to rewrite on 25. A team adopting it on 25 should expect changes again before it is final, and if the next LTS is 29, there are four releases in between in which the shape could move.
The second cost is less obvious and more serious for a platform. Class files compiled with preview features carry a special minor version and run only on the exact JDK version that compiled them, and only with --enable-preview. So a service built on 25 with preview features cannot run on a newer JDK at all without being recompiled. If that code sits in a shared library, every service that depends on the library is pinned to 25 until the library is rebuilt and adjusted. The platform loses its ability to upgrade services independently, which is exactly what keeps fleet upgrades cheap.
There is also a support angle: some vendors and tools treat preview use as unsupported, and some static analysis or bytecode tools lag on preview class files.
3The Policy: Experiments Yes, Production No, With a Real Exception Path
So the default is clear: no preview features in production code. Experiments, prototypes, benchmarks and internal tools that we can rebuild at will are welcome, because that is what previews are for. A sandbox repository where engineers try the API on real problems costs little and teaches a lot.
A blanket ban, though, pushes teams to work around the policy. So there is an exception path with conditions. A named owner signs up to keep the code working at every JDK upgrade. The preview code is isolated in one module behind our own interface, never in a shared library. The service records which JDK it is pinned to, and the exception has a review date, at the latest when the feature becomes final or when the next LTS arrives. And the team states the benefit in numbers, for example a latency reduction we measured, so the decision is not about novelty.
- Team asks to use a preview APIfor example structured concurrency on 25
- Is it production code?YesGo to the exception checksNoAllowed: experiments, tools, benchmarks
- Is there a measured benefit no final API gives?YesContinueNoUse final APIs such as ExecutorService
- Can it be isolated in one module behind an interface?YesGrant a time-boxed exceptionNoDecline for now
- Owner, pinned JDK and review date recordedrevisit at each release and when final
5 steps in order. Play them, or step through them one at a time.
Most requests end in the sandbox or with a final API; exceptions are rare and owned.
4Isolating the Code If We Grant an Exception
Isolation keeps the blast radius small. We define our own small interface for what we need, which is usually run these calls concurrently and fail fast. The production implementation uses final APIs. A second implementation uses structured concurrency and is selected only in that one service.
If the API changes in 26 or 27, we rewrite one class. If we need to move to a JDK the owner has not yet caught up with, we switch the service back to the executor version and keep upgrading. The rest of the code base never knows preview features existed.
5Closing the Loop With OpenJDK
Previews exist to collect feedback from real use. So the policy should push teams to send it: a short, concrete message to the loom-dev mailing list describing what worked, what was awkward and what they needed, with a small code example. The redesign of the structured concurrency API in Java 25 came from exactly this kind of feedback.
This turns the team's enthusiasm into something useful for everyone and builds the company's credibility in the community. It is also good for the engineers, who learn the API deeply and will be ready to roll it out widely once it is final.
6Follow-up questions
Would you allow virtual threads, which are final, in the same service?
Yes. Virtual threads have been final since Java 21 and are a normal, supported API. Combining them with an ExecutorService gives most of the practical benefit today; structured concurrency adds cleaner cancellation and error handling on top.
What if the team says the feature will surely be final soon?
That may well be true, but we cannot plan on it, and the shape can still change in the final version, as it did between 24 and 25. If it becomes final in a non-LTS release, we also have to wait for the next LTS for production use, so the honest timeline is often longer than the team expects.
How do you enforce the policy?
Mostly through the build: the platform's parent build fails if --enable-preview appears outside modules on an approved list, and CI scans class files for minor version 65535. Enforcement in the build is cheaper and fairer than review comments.
7Conclusion
In this answer, we saw that structured concurrency is still a preview API in Java 25 and has already changed shape, and that preview class files run only on the JDK that compiled them, which blocks independent upgrades. The policy is no preview features in production by default, generous use in experiments and tools, a rare exception with an owner, isolation behind an interface and a review date, and active feedback to OpenJDK.
Open with
My default policy is no preview features in production code, and structured concurrency in Java 25 falls under it. There are two concrete reasons. First, preview APIs change: this one went from ShutdownOnFailure subclasses to the open method with joiners in Java 25, so code written on 21 did not compile on 25.
Then, if they want more
Second, preview class files only run on the exact JDK that compiled them, with --enable-preview, so that code pins the service, or worse every user of a shared library, to one version, and we lose independent upgrades. That said, I do not want a flat no. Teams can use it freely in experiments, benchmarks and internal tools.
For production I would allow an exception only with a measured benefit, a named owner who handles every upgrade, the code isolated in one module behind our own interface with a fallback on final APIs like a virtual thread executor, and a review date.
And I would ask the team to send their findings to the loom-dev list, because feedback is the whole point of a preview.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 25, Java 21, Java 24
- 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
- The Java Language Specification, Java SE 21, Java SE 21 API documentation
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 "A team wants to use structured concurrency, still in preview in Java 25, in a production...": https://scrivio-interview-library.netlify.app/java/java-versions/860f7bdaf8/