Class ThreadLocalMap

java.lang.Object
org.miaixz.bus.core.lang.thread.threadlocal.ThreadLocalMap

public final class ThreadLocalMap extends Object
存储所有 SpecificThreadThreadLocal 变量的内部数据结构。 请注意,此类仅供内部使用。除非知道自己在做什么,否则请使用 SpecificThread
Since:
Java 17+
Author:
Kimi Liu
  • Field Details

    • UNSET

      public static final Object UNSET
      无效的value值(占位符),不使用null做无效值的原因是因为netty认为null也是一个有效值, 例如:假设没有重写FastThreadLocal的initialValue()方法,则该方法返回为null,会将null作为有效值直接存储起来
    • VARIABLES_TO_REMOVE_INDEX

      public static final int VARIABLES_TO_REMOVE_INDEX
      要删除的变量索引
  • Method Details

    • get

      public static ThreadLocalMap get()
      获取ThreadLocalMap实例
      Returns:
      ThreadLocalMap
    • getIfSet

      public static ThreadLocalMap getIfSet()
      获取当前线程信息
      Returns:
      ThreadLocalMap
    • remove

      public static void remove()
      删除当前线程的ThreadLocalMap
    • destroy

      public static void destroy()
      销毁线程信息
    • nextVariableIndex

      public static int nextVariableIndex()
      获取FastThreadLocal的唯一索引
      Returns:
      the int
    • size

      public int size()
      当前线程大小
      Returns:
      the int
    • isIndexedVariableSet

      public boolean isIndexedVariableSet(int index)
      是否索引变量集
      Parameters:
      index - 索引
      Returns:
      the true/false
    • indexedVariable

      public Object indexedVariable(int index)
      获取指定位置的元素
      Parameters:
      index - 索引
      Returns:
      the object
    • setIndexedVariable

      public boolean setIndexedVariable(int index, Object value)
      设置索引变量
      Parameters:
      index - 索引
      value - 变量值
      Returns:
      @code true} 当且仅当创建了新的线程局部变量时
    • removeIndexedVariable

      public Object removeIndexedVariable(int index)
      删除指定位置的对象
      Parameters:
      index - 索引
      Returns:
      the object
    • setCleanerFlags

      public void setCleanerFlags(int index)
      设置当前索引位置index(FastThreadLocal)的bit为1
    • isCleanerFlags

      public boolean isCleanerFlags(int index)
      获取 当前index的bit值,1表示true,0表示false(默认值)