Chapter 15. Modern Performance and The Future
In this chapter, we will look to the future of performance for Java and the JVM, especially as it relates to the reality of cloud native deployments. We will discuss several technologies that are not present (or present only as incubator or preview features) in Java 21. This reflects the principle that we only cover final features present in an LTS version in the main part of the book, and we reserve discussion of non-final features until this chapter.
New Concurrency Patterns
In this section, we’re going to discuss some new patterns for concurrent systems that are enabled by virtual threads and some related new features that “follow on” from virtual threads—specifically structured concurrency (JEP 453) and scoped values (JEP 446).
Note that, as of JDK 21, both structured concurrency and scoped values are in preview state, so they cannot be used in production applications.
Structured Concurrency
The first of the two new APIs is known as structured concurrency. This is an API for thread handling, which provides an approach for cooperating tasks (usually virtual threads) to be considered and managed collectively as a collection of subtasks.
It might help to recall the discussion of Amdahl’s law in Chapter 13, where we described the application of concurrent techniques to data-parallel problems.
In contrast, structured concurrency is designed for task-parallel problems and, because of its affinity to virtual threads, it is primarily ...
Get Optimizing Cloud Native Java, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.