java.lang.ThreadLocal with
the one major upside of a removeAll() method that
can be used to remove ALL instances of all thread locals on
ALL threads from any other thread.
| Modifier and Type | Class and Description |
|---|---|
| private static class | Hk2ThreadLocal.
A weakly referenced thread suitable as a map key. |
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private static final Object | |
| private final ReferenceQueue |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public V | Returns: the current thread's value of this thread-localReturns the value in the current thread's copy of this thread-local variable. |
| public int | Returns: The current number of entries across all threads. This is basically the number of threads that currently have data with the Hk2ThreadLocalReturns the total size of the internal data structure in terms of entries. |
| protected V | Returns: the initial value for this thread-localReturns the current thread's "initial value" for this thread-local variable. |
| private static Object | |
| private static Hk2ThreadLocal. | |
| private static Hk2ThreadLocal. | Returns: The key.The reference queue. queue)Create a key for the current thread that will be enqueued unless cleared. |
| public void | |
| public void | |
| private void | |
| public void | set(V
the value to be stored in the current thread's copy of
this thread-local. value)Sets the current thread's copy of this thread-local variable to the specified value. |
| private static Object | Returns: The value ornull.The value or sentinel. value)Replace a sentinel with |
| locals | back to summary |
|---|---|
| private final Map<Hk2ThreadLocal. | |
| NULL | back to summary |
|---|---|
| private static final Object NULL | |
| queue | back to summary |
|---|---|
| private final ReferenceQueue<Thread> queue | |
| Hk2ThreadLocal | back to summary |
|---|---|
| public Hk2ThreadLocal() | |
| get | back to summary |
|---|---|
| public V get() Returns the value in the current thread's copy of this
thread-local variable. If the variable has no value for the
current thread, it is first initialized to the value returned
by an invocation of the
| |
| getSize | back to summary |
|---|---|
| public int getSize() Returns the total size of the internal data structure in terms of entries. This is used for diagnostics purposes only
| |
| initialValue | back to summary |
|---|---|
| protected V initialValue() Returns the current thread's "initial value" for this
thread-local variable. This method will be invoked the first
time a thread accesses the variable with the This implementation simply returns null; if the programmer desires thread-local variables to have an initial value other than null, ThreadLocal must be subclassed, and this method overridden. Typically, an anonymous inner class will be used.
| |
| maskNull | back to summary |
|---|---|
| private static Object maskNull(Object value) Replace a | |
| newLookupKey | back to summary |
|---|---|
| private static Hk2ThreadLocal. Create a key for the current thread that will not be enqueued. Using this
method (or clearing a 'storage' key) ensures that no extra work is required
in
| |
| newStorageKey | back to summary |
|---|---|
| private static Hk2ThreadLocal. Create a key for the current thread that will be enqueued unless cleared. All keys actually stored in the map must be created by this method and must not be explicitly cleared.
| |
| remove | back to summary |
|---|---|
| public void remove() Removes the current thread's value for this thread-local
variable. If this thread-local variable is subsequently
read by the current thread, its value will be
reinitialized by invoking its | |
| removeAll | back to summary |
|---|---|
| public void removeAll() Removes all threads current thread's value for this thread-local
variable. If this thread-local variable is subsequently
read by the current thread, its value will be
reinitialized by invoking its | |
| removeStaleEntries | back to summary |
|---|---|
| private void removeStaleEntries() Removes from the map any key that has been enqueued by the garbage collector. | |
| set | back to summary |
|---|---|
| public void set(V value) Sets the current thread's copy of this thread-local variable
to the specified value. Most subclasses will have no need to
override this method, relying solely on the
| |
| unmaskNull | back to summary |
|---|---|
| private static Object unmaskNull(Object value) Replace a sentinel with | |
| Modifier and Type | Field and Description |
|---|---|
| private final int | |
| private final long |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object obj)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public int |
| hash | back to summary |
|---|---|
| private final int hash | |
| threadId | back to summary |
|---|---|
| private final long threadId | |
| Key | back to summary |
|---|---|
| private Key(Thread thread, ReferenceQueue<Thread> queue) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |