Spec-Zone .ru
спецификации, руководства, описания, API
|
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.ThreadLocal
This class provides ThreadLocal variables. These variables differ from their normal counterparts in that each thread that accesses one (via its get or set method) has its own, independently initialized copy of the variable. ThreadLocal objects are typically private static variables in classes that wish to associate state with a thread (e.g., a user ID or Transaction ID).
Each thread holds an implicit reference to its copy of a ThreadLocal as long as the thread is alive and the ThreadLocal object is accessible; after a thread goes away, all of its copies of ThreadLocal variables are subject to garbage collection (unless other references to these copies exist).
Constructor Summary | |
ThreadLocal()
Creates a ThreadLocal variable. |
Method Summary | |
Object |
get()
Returns the value in the calling thread's copy of this ThreadLocal variable. |
protected Object |
initialValue()
Returns the calling thread's initial value for this ThreadLocal variable. |
void |
set(Object value)
Sets the calling thread's instance of this ThreadLocal variable to the given value. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public ThreadLocal()
Method Detail |
protected Object initialValue()
public Object get()
public void set(Object value)
value
- the value to be stored in the calling threads' copy of
this ThreadLocal.
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |