类 InternalThreadLocal<V>


  • public class InternalThreadLocal<V>
    extends 
    InternalThreadLocal A special variant of 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 {@see io.netty.util.concurrent.FastThreadLocal} which is in Netty.
    • 方法概要

      所有方法 静态方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      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.
      • 从类继承的方法 java.lang.

        , , , , , , , ,
    • 构造器详细资料

      • InternalThreadLocal

        public InternalThreadLocal()
    • 方法详细资料

      • removeAll

        public static void removeAll()
        Removes all 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.
      • 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.