English 中文(简体)
Java.lang - ThreadLocal
  • 时间:2024-12-22

Java.lang.ThreadLocal Class


Previous Page Next Page  

Introduction

The java.lang.ThreadLocal class provides thread-local variables.

Class Declaration

Following is the declaration for java.lang.ThreadLocal class −

pubpc class ThreadLocal<T>
   extends Object

Class constructors

Sr.No. Constructor & Description
1

ThreadLocal()

This creates a thread local variable.

Class methods

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.

Methods inherited

This class inherits methods from the following classes −

    java.lang.Object

Advertisements