StructuredTaskScope And ScopedValue - Get The Most Out of Virtual Threads
summary
A live‑coded Spring Boot app uses Java 21 virtual threads plus preview features from Java 25 to replace blocking REST calls with concurrent subtasks, showing JMeter with 1,000 concurrent users drop worst‑case responses from ~4s to ~1s (sleeped endpoints: 1s and 3×500ms). A custom StructuredTaskScope joiner (info joiner) aggregates only successful results and preserves exceptions; ScopedValue replaces ThreadLocal so per‑request context survives child virtual threads. The example compiles, runs, and demonstrates concrete performance and correctness gains.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 1:49Virtual threads overview
- 11:21Why virtual threads aren't enough
- 17:01StructuredTaskScope basics
- 21:58Custom joiner implementation
- 28:40Benefits of structured task scopes
- 32:33Thread locals vs scope values
- 42:30Recap and summary
- 43:10Q&A
related talks
44mStructuredTaskScope And ScopedValue - Get The Most Out of Virtual Threads
44mStructuredTaskScope And ScopedValue - Get The Most Out of Virtual Threads
38mStructuredTaskScope And ScopedValue - Get The Most Out of Virtual Threads
01h 03mBeyond Virtual Threads: Structured Concurrency
42mVirtual Threads, Structured Concurrency and Scoped Values: Putting it all together
44mGet The Most Out of Virtual Threads in Java 25: A Deep Dive
48mVirtual Threads, Structured Concurrency and Scoped Values: Putting it all together
47mVirtual Threads, Structured Concurrency & Scoped Values: Putting it All Together
