类 InternalThreadLocal<V>
- java.lang.Object
-
- com.alibaba.dubbo.common.threadlocal.InternalThreadLocal<V>
-
public class InternalThreadLocal<V> extends Object
InternalThreadLocal A special variant ofThreadLocalthat yields higher access performance when accessed from aInternalThread. Internally, aInternalThreaduses 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 {@see io.netty.util.concurrent.FastThreadLocal} which is in Netty.
-
-
构造器概要
构造器 构造器 说明 InternalThreadLocal()
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 static voiddestroy()Vget()Returns the current value for the current threadvoidremove()Sets the value to uninitialized; a proceeding call to get() will trigger a call to initialValue().voidremove(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 voidremoveAll()Removes allInternalThreadLocalvariables bound to the current thread.voidset(V value)Sets the value for the current thread.static intsize()Returns the number of thread local variables bound to the current thread.
-
-
-
方法详细资料
-
removeAll
public static void removeAll()
Removes allInternalThreadLocalvariables 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.
-
size
public static int size()
Returns the number of thread local variables bound to the current thread.
-
destroy
public static void destroy()
-
get
public final V get()
Returns the current value for the current thread
-
set
public final void set(V value)
Sets the value for the current thread.
-
remove
public final void remove()
Sets the value to uninitialized; a proceeding call to get() will trigger a call to initialValue().
-
remove
public final 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(). The specified thread local map must be for the current thread.
-
-