public class ThreadLocal extends Object
ThreadLocal
object,
but each sees a different value when accessing it, and changes made by one
thread do not affect the other threads. The implementation supports
null
values.Thread
Constructor and Description |
---|
ThreadLocal()
Creates a new thread-local variable.
|
Modifier and Type | Method and Description |
---|---|
Object |
get()
Returns the value of this variable for the current thread.
|
protected Object |
initialValue()
Provides the initial value of this variable for the current thread.
|
void |
set(Object value)
Sets the value of this variable for the current thread.
|
public Object get()
initialValue()
.protected Object initialValue()
null
.public void set(Object value)
null
, the value will be set to null and the underlying entry will
still be present.value
- the new value of the variable for the caller thread.