Thread-local storage (TLS) gives each thread its own independent copy of a variable. Unlike a global variable, a thread-local value stays private to the thread that writes it. section 14.4.1
For observability, Mapped Diagnostic Context (MDC) uses thread-local storage to associate request details—such as a tenantId, orderId, or correlationId—with the active thread. Logging can then add that context to messages throughout the call stack without passing telemetry values through business method signatures. section 14.4.1
Figure 14.6 Mapped Diagnostic Context gives every execution thread a private sandbox.

A private-sandbox diagram illustrates how each execution thread keeps its own context. section 14.4.1
Scope checkout context
A checkout operation can place its orderId in MDC for the duration of a try-with-resources block. Logs emitted within that block, including deeper calls, carry the identifier; leaving the block removes it to prevent leaks or contamination of later work. section 14.7.2

