public class InternalThreadLocal<V> extends Object
ThreadLocal that yields higher access performance when accessed from a
InternalThread.
Internally, a InternalThread uses a constant index in an array, instead of using hash code and hash table,
to look for a variable. Although seemingly very subtle, it yields slight performance advantage over using a hash
table, and it is useful when accessed frequently.
This design is learning from io.netty.util.concurrent.FastThreadLocal which is in Netty.| 构造器和说明 |
|---|
InternalThreadLocal() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
destroy() |
V |
get()
Returns the current value for the current thread
|
void |
remove()
Sets the value to uninitialized; a proceeding call to get() will trigger a call to initialValue().
|
void |
remove(InternalThreadLocalMap threadLocalMap)
Sets the value to uninitialized for the specified thread local map;
a proceeding call to get() will trigger a call to initialValue().
|
static void |
removeAll()
Removes all
InternalThreadLocal variables bound to the current thread. |
void |
set(V value)
Sets the value for the current thread.
|
static int |
size()
Returns the number of thread local variables bound to the current thread.
|
public static void removeAll()
InternalThreadLocal variables bound to the current thread. This operation is useful when you
are in a container environment, and you don't want to leave the thread local variables in the threads you do not
manage.public static int size()
public static void destroy()
public final V get()
public final void set(V value)
public final void remove()
public final void remove(InternalThreadLocalMap threadLocalMap)
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.