Structured Concurrency in Java
summary
Java 21’s structured concurrency is shown as a concrete replacement for raw executors using StructuredTaskScope and virtual threads, with a live demo that forks subtasks to resolve mocked IATA airport names and uses joinUntil with a 10s timeout. Code examples implement shutdownOnFailure (one child fails then interrupts others), shutdownOnSuccess (first success cancels remaining), result() and throwIfFailed, and a preview scoped values API for immutable per-scope data; warning: APIs are preview and not production stable.
AI-written summary · about
chapters (13)
- 0:00Introduction to structured concurrency
- 1:47Concurrency problems and history
- 8:12Parent-child task relationships
- 16:24Why structured concurrency
- 19:12Basic structured task scope
- 25:22Never block without timeout
- 31:48Shutdown on failure
- 35:50Shutdown on success
- 42:17Collecting results and exceptions
- 45:10Real-world use cases
- 47:58Key features and benefits
- 49:24Scoped values overview
- 56:57Summary and closing
related talks
43mStructured Concurrency in Java - The What and the Why
49mJava's Concurrency Journey Continues! Structured Concurrency & Scoped Values
41mStructured Concurrency in Java: The What & Why
02h 17mJava's Concurrency Journey Continues! Exploring Structured Concurrency and Scoped Values
48mMake Your Code Parallel with the Structured Concurrency API
50mStructured Concurrency: Managing the Hierarchical Cancelation and Error Handling
34mIntroduction and pitfalls of Java's new concurrency model
51mIntroduction and Pitfalls of Java's New Concurrency Model
