StructuredTaskScope And ScopedValue - Get The Most Out of Virtual Threads
summary
Live-coding builds a Spring Boot demo that swaps blocking REST calls for virtual threads plus StructuredTaskScope and ScopedValue (both in third preview), showing how to fork/join virtual-thread subtasks, extend StructuredTaskScope for aggregation, and replace ThreadLocal with ScopedValue so child scopes see values. Under JMeter with 1,000 concurrent users the demo drops median latency from about 2.5 seconds to 1 second by parallelizing IO; ThreadLocal becomes null inside child virtual threads while ScopedValue retains the header.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 1:26Virtual threads overview
- 6:20Fixing performance
- 10:52StructuredTaskScope intro
- 16:36Replacing reactive code
- 21:37Cleaner code with StructuredTaskScope
- 24:46Concurrent tasks
- 27:57Benchmarking performance
- 29:00Key benefits
- 30:26ScopedValues vs ThreadLocals
- 36:04When to use ScopedValues
- 39:14Recap
- 39:56Q&A
related talks
49mStructuredTaskScope And ScopedValue - Get The Most Out of Virtual Threads
38mStructuredTaskScope And ScopedValue - Get The Most Out of Virtual Threads
44mStructuredTaskScope 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
48mVirtual Threads, Structured Concurrency and Scoped Values: Putting it all together
44mGet The Most Out of Virtual Threads in Java 25: A Deep Dive
47mVirtual Threads, Structured Concurrency & Scoped Values: Putting it All Together
