Modern Backend - Range Values (1)

Modern Backend - Range Values (1)

The first lecture of the sixth session in Part 1 of the [Modern Backend] course, "Scoped Values (1)."
In this lecture, we take an in-depth look at the background and need for Scoped Values, officially adopted as a standard feature in Java 25, as well as the structural limitations and risks of ThreadLocal, which has long been used for sharing context.

📌 Key topics:

  • Comparison of three ways to pass common data between layers (authentication, trace IDs, etc.): parameter passing / static holders / scoped values

  • Analysis of the internal structure of ThreadLocalMap and the causes of memory leaks / information exposure incidents

  • Three limitations of ThreadLocal (mutability, lifetime management, inheritance costs)

  • Review of the instability of manually passing context (set/clear) by analyzing the code from the previous fifth lecture

  • Why the premise of reusing ThreadLocal breaks down in the era of virtual threads

  • InheritableThreadLocal vs ScopedValue (heavy map copying vs lightweight reference sharing and guaranteed immutability)

Step by step, explore the design background of Scoped Values, which safely enforces the valid scope of data at the language level, moving beyond the existing approach that relied solely on developers' caution.

Site footer