Android
java.lang
public class

java.lang.ThreadLocal<T>

java.lang.Object
java.lang.ThreadLocal<T>

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

Known Direct Subclasses

See Also

Summary

Public Constructors

            ThreadLocal()
Creates a new thread local variable.

Public Methods

          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

          initialValue()
Provides the initial value of this variable for the current thread.
Methods inherited from class java.lang.Object

Details

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.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48