Package org.springframework.core
Class NamedThreadLocal<T>
java.lang.Object
java.lang.ThreadLocal<T>
org.springframework.core.NamedThreadLocal<T>
- Type Parameters:
T
- the value type
ThreadLocal
subclass that exposes a specified name
as toString()
result (allowing for introspection).- Since:
- 2.5.2
- Author:
- Juergen Hoeller, Qimiao Chen
- See Also:
-
Constructor Summary
ConstructorDescriptionNamedThreadLocal
(String name) Create a new NamedThreadLocal with the given name. -
Method Summary
Modifier and TypeMethodDescriptiontoString()
static <S> ThreadLocal<S>
withInitial
(String name, Supplier<? extends S> supplier) Create a named thread local variable.Methods inherited from class java.lang.ThreadLocal
get, initialValue, remove, set, withInitial
-
Constructor Details
-
NamedThreadLocal
Create a new NamedThreadLocal with the given name.- Parameters:
name
- a descriptive name for this ThreadLocal
-
-
Method Details
-
toString
-
withInitial
Create a named thread local variable. The initial value of the variable is determined by invoking theget
method on theSupplier
.- Type Parameters:
S
- the type of the named thread local's value- Parameters:
name
- a descriptive name for the thread localsupplier
- the supplier to be used to determine the initial value- Returns:
- a new named thread local
- Since:
- 6.1
-