StructuredTaskScope And ScopedValue - Get The Most Out of Virtual Threads
summary
Demonstrates using Java 21 virtual threads plus two Java preview features StructuredTaskScope and ScopedValue to convert an empty Spring Boot app (tested on Spring Boot 3.3 / Java 23) into a concurrent web service. Live code shows enabling spring.threads.virtual.enabled, JMeter with 1,000 concurrent users and a 200-thread pool (responses rose to ~4–5s); switching to virtual threads cuts simple calls to ~1s. Adding StructuredTaskScope runs three info calls concurrently (2.5s → ~1.5s), nesting scopes to parallelize talk and infos reaches ~1s. Explains thread locals fail across virtual-thread subtasks while scoped values are read-only and inherited by child scopes.
AI-written summary · about
chapters (10)
- 0:00Introduction
- 1:46Virtual threads matter
- 6:02Virtual threads demo
- 11:17Limitations of virtual threads
- 16:56Structured concurrency
- 22:20Custom task scopes
- 27:42Sealed interfaces with scopes
- 31:11Thread locals vs scoped values
- 38:55Recap
- 39:37Q&A
related talks
49mStructuredTaskScope 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
48mVirtual Threads, Structured Concurrency and Scoped Values: Putting it all together
47mVirtual Threads, Structured Concurrency & Scoped Values: Putting it All Together
44mGet The Most Out of Virtual Threads in Java 25: A Deep Dive
