Upcoming Java 21 brings a bunch of new features, including very interesting progress in concurrency. There are two main improvements – virtual threads and structured concurrency.
In this article, we discuss incoming usage of these enhancements inJakarta EE (formerly Java EE, now an open source project maintained by the Eclipse Foundation), a set of specifications that enables the worldwide community of Java developers to work on cloud native Java enterprise applications. Jakarta Concurrency is the concrete specification describing the expected behaviour.
The support in Jakarta EE is currently under development, details may change in the final implementation.
Jakarta Concurrency
A quick reminder, this is where Jakarta Concurrency is used in the server. See the orange-colored part of the diagram!
Virtual threads improve application throughput, which is the biggest value for server-side Java applications. Java Virtual Machine (JVM) handles the virtual threads in a more effective way, as there are less real (platform, carrier, operating system) threads running the code. Java maps the required work in virtual threads to platform threads. Whenever the thread is blocked (e.g. waiting for database, REST call etc.), the platform thread switches to execute another virtual thread. The relation between virtual and platform threads is shown here:
There are several more advantages. Less memory is required for multiple threads, it is kept in Java heap instead of limited native memory. They are kept in Java, so they don’t reach the Thread’s OutOfMemory if too many of them are used.
Virtual Threads in Jakarta EE 11
Jakarta 11is the upcoming new release of the Jakarta EE Platform, with a target release date of the first quarter of 2024, roughly six months after the target release for Java 21.
In Jakarta EE, applications run inside servers. The servers provide resources, in this case threads. They enhance threads by context (access to database, HTTP requests, logged in user etc.) and also allow administrators control the behavior of the server by setting up thread pools, setting for example priority or pool size…
This means, that programmers don’t create threads manually, but rely on Jakarta EE API. The most common way is to use @ManagedExecutorService:
The second big improvement of Java 21 is structured concurrency. It is replacing thread locals with a safer way. Instead of setting up thread local, the user specifies the shared objects in try block. At the end of the block, the object is no longer shared, e.g. it cannot be forgotten in thread local. For example:
How to Run and Scale AI Java Applications in Production: An Overview for Developers with no Machine Learning Expertise
Organizations are increasingly interested in adopting artificial intelligence (AI) and generative AI (GenAI) to improve operations and offer next-generation […]
3 minutes
Community
Dominika Tasarz
30 Sep 2025
The Payara Monthly Catch -September 2025
Welcome aboard the September issue of The Monthly Catch! With summer holidays wrapping up, the Java world is back […]
4 minutes
Security
Asif Khan
29 Sep 2025
Zero Trust Security in Enterprise Java: What it is and How to Implement it
Cybersecurity isn’t just about building walls, fortresses, moats or any other external barrier anymore. Nowadays, it’s important to check […]