Structured Concurrency on the JVM

Jeroen Rosenberg
Jeroen Rosenberg
Published in
19 min readJan 10, 2024

--

Structured concurrency is a programming paradigm aimed at providing a more organised and predictable way to manage concurrent execution in software programs. It addresses many of the challenges and complexities associated with traditional concurrent programming models, such as resource leaks, manual synchronisation and “callback hell”.

Java 19 has incorporated an API for structured concurrency (although it’s still in the incubator phase), a feature that Kotlin has long provided through its Coroutines and suspending functions. My recent exploration led me to the Ox library, which extends the benefits of structured concurrency to Scala, leveraging Java’s concurrency API. In this article, I’ll illustrate what structured concurrency entails. Furthermore, I’ll delve into a comparison between the Ox library in Scala and Kotlin Coroutines, shedding light on their respective strengths and features with regards to structured concurrency.

Structured Concurrency

Before we jump into the comparison of structured concurrency APIs on the JVM, let’s first establish clear definitions for both concurrency and structured concurrency.

Concurrency vs. Parallelism

When we talk about concurrency it’s important to note that this doesn’t necessarily refer to parallel execution…

--

--

Jeroen Rosenberg
Jeroen Rosenberg

Dev of the Ops. Founder of Amsterdam.scala. Passionate about Agile, Continuous Delivery. Proud father of three.