In September 2023, Java 21 brought a revolution through virtual threads, while Oracle, in version 26ai (23ai), introduced the concept of “virtual transactions.” In the following sections, discover how the synergy of these technologies, along with a “third player,” is fundamentally changing the architecture of modern web applications.
ABSTRACT
In September 2023, the Java programming language introduced Java virtual threads in its long-term support version 21 (previously available only as a prototype solution).
While Java non-virtual (platform) threads are mapped 1:1 to operating system threads, multiple Java virtual threads can run on a single platform thread. This makes their number practically unlimited, allowing for the development of code that is as efficient as asynchronous code, but more readable, easier to debug, and provides clearer error reporting, exceptions.
In Oracle Database 26ai (formerly known as 23ai), Oracle introduced sessionless transactions, which are referred to in this paper as “virtual transactions” to reflect their similarity to Java virtual threads. Traditionally, transaction management requires connection and session resources to be bound to the transaction throughout its entire lifecycle. Consequently, a session/connection can only be released after the transaction has ended, often resulting in the underutilization of sessions and connections.
With sessionless transactions, once a transaction is started, we have the flexibility to suspend and resume it during its lifecycle. The session/connection can be returned to the pool of free sessions/connections and reused by other transactions.
Both of these features – Java virtual threads and Oracle “virtual transactions” are highly beneficial on their own. Using them simultaneously could be the ideal match. However, there is also a “third player”! Together, they can significantly impact the architectural shift of web applications (working with databases).