Class ThreadLocalMap
java.lang.Object
org.miaixz.bus.core.lang.thread.threadlocal.ThreadLocalMap
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Object无效的value值(占位符),不使用null做无效值的原因是因为netty认为null也是一个有效值, 例如:假设没有重写FastThreadLocal的initialValue()方法,则该方法返回为null,会将null作为有效值直接存储起来static final int要删除的变量索引 -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddestroy()销毁线程信息static ThreadLocalMapget()获取ThreadLocalMap实例static ThreadLocalMapgetIfSet()获取当前线程信息indexedVariable(int index) 获取指定位置的元素booleanisCleanerFlags(int index) 获取 当前index的bit值,1表示true,0表示false(默认值)booleanisIndexedVariableSet(int index) 是否索引变量集static int获取FastThreadLocal的唯一索引static voidremove()删除当前线程的ThreadLocalMapremoveIndexedVariable(int index) 删除指定位置的对象voidsetCleanerFlags(int index) 设置当前索引位置index(FastThreadLocal)的bit为1booleansetIndexedVariable(int index, Object value) 设置索引变量intsize()当前线程大小
-
Field Details
-
UNSET
无效的value值(占位符),不使用null做无效值的原因是因为netty认为null也是一个有效值, 例如:假设没有重写FastThreadLocal的initialValue()方法,则该方法返回为null,会将null作为有效值直接存储起来 -
VARIABLES_TO_REMOVE_INDEX
public static final int VARIABLES_TO_REMOVE_INDEX要删除的变量索引
-
-
Method Details
-
get
获取ThreadLocalMap实例- Returns:
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
获取指定位置的元素- Parameters:
index- 索引- Returns:
- the object
-
setIndexedVariable
设置索引变量- Parameters:
index- 索引value- 变量值- Returns:
- @code true} 当且仅当创建了新的线程局部变量时
-
removeIndexedVariable
删除指定位置的对象- 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(默认值)
-