📜  Java.lang.ThreadLocal类

📅  最后修改于: 2020-11-15 03:10:16             🧑  作者: Mango


介绍

java.lang.ThreadLocal类提供线程局部变量。

类声明

以下是java.lang.ThreadLocal类的声明-

public class ThreadLocal
   extends Object

类的构造函数

Sr.No. Constructor & Description
1

ThreadLocal()

This creates a thread local variable.

类方法

Sr.No. Method & Description
1 T get()

This method returns the value in the current thread’s copy of this thread-local variable.

2 protected T initialValue()

This method returns the current thread’s “initial value” for this thread-local variable.

3 void remove()

This method removes the current thread’s value for this thread-local variable.

4 void set(T value)

This method sets the current thread’s copy of this thread-local variable to the specified value.

方法继承

此类从以下类继承方法-

  • java.lang.Object