Why it matters
ThreadLocal has issues with virtual threads. ScopedValue solves. Understanding shapes modern Java concurrency.
Advertisement
The architecture
ScopedValue.where(sv, value).run(runnable).
Value visible in runnable scope; hidden outside.
Advertisement
How it works end to end
Immutable: unlike ThreadLocal, value can't change within scope.
Structured: naturally aligned with structured concurrency.
Performance: no leaks; no synchronization.