Make Your Code Parallel with the Structured Concurrency API
summary
Structured Concurrency arrives as a preview API (structured task scopes in JDK26 preview) that pairs StructuredTaskScope with virtual threads and scope values to launch parallel network requests, produce meaningful stack traces that point into the submitted lambda, and auto-clean threads when the scope closes. Code forks tasks, calls join (or uses a configurable Joiner strategy), and close interrupts remaining threads; timeouts can cancel or return partial results. Virtual threads are cheap, long in‑memory computations are discouraged, and incorrect onComplete code risks races.
AI-written summary · about
chapters (10)
- 0:00Project Loom and structured concurrency
- 4:25Problems Project Loom solves
- 9:47Thread locals vs scope values
- 13:26Goto and concurrency issues
- 17:21Structured concurrency fixes threads
- 24:04Structured concurrency API deep dive
- 30:06Configuring task scope joiner
- 35:46Callbacks in structured concurrency
- 40:18Handling results and exceptions
- 46:39Summary and next steps
related talks
43mStructured Concurrency in Java - The What and the Why
41mStructured Concurrency in Java: The What & Why
57mStructured Concurrency in Java
49mJava's Concurrency Journey Continues! Structured Concurrency & Scoped Values
51mIntroduction and Pitfalls of Java's New Concurrency Model
01h 03mBeyond Virtual Threads: Structured Concurrency
34mIntroduction and pitfalls of Java's new concurrency model
02h 17mJava's Concurrency Journey Continues! Exploring Structured Concurrency and Scoped Values
