加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090303144419/http://developer.android.com:80/reference/java/lang/ThreadLocal.html
public class

ThreadLocal

extends Object
java.lang.Object
   ↳ java.lang.ThreadLocal<T>
Known Direct Subclasses

Class Overview

A variable for which each thread has its own value. Supports null values.

See Also

Summary

Public Constructors
ThreadLocal()
Creates a new thread local variable.
Public Methods
T get()
Returns the value of this variable for the current thread.
void remove()
Removes the entry for this variable in the current thread.
void set(T value)
Sets the value of this variable for the current thread.
Protected Methods
T initialValue()
Provides the initial value of this variable for the current thread.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ThreadLocal ()

Creates a new thread local variable.

Public Methods

public T get ()

Returns the value of this variable for the current thread. If an entry doesn't yet exist for this variable on this thread, this method will create an entry, populating the value with the result of initialValue().

public void remove ()

Removes the entry for this variable in the current thread. If this call is followed by a get() before a set(T), #get() will call initialValue() and create a new entry with the resulting value.

public void set (T value)

Sets the value of this variable for the current thread. If set to null, the value will be set to null and the underlying entry will still be present.

Protected Methods

protected T initialValue ()

Provides the initial value of this variable for the current thread. The default implementation returns null.