JEP 487: Scoped Values (Fourth Preview)

Differences wirth thread local

  • no "two way" mutability

  • defined lifetime

    • memory leaks for pooled threads

Demo

Basic example in one thread

ScopedValueDemoSimpleExample

Example how to propagate ScopedValue with Structured concurrency

ScopedValueStructureConcurrencyDemo

Last updated