aicas logoJamaica 6.4 release 1

java.lang
Class ThreadLocal<T>

java.lang.Object
  extended by java.lang.ThreadLocal<T>
Direct Known Subclasses:
InheritableThreadLocal

public class ThreadLocal<T>
extends Object

ThreadLocal provides thread local variables, i.e., variables for which each thread that uses them has its own private copy.

Since:
1.2

Constructor Summary
ThreadLocal()
          Constructor to create a thread local variable.
 
Method Summary
 T get()
          get returns the current value in the current' threads local instance of this thread local variable.
protected  T initialValue()
          initialValue returns an initial value for this variable.
 void remove()
          Remove this thread local variable (from current thread or from all threads?), reset value to initialValue.
 void set(T value)
          set sets the current thread's value of this thread local variable to the given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadLocal

public ThreadLocal()
Constructor to create a thread local variable.

For JamaicaVM: Please note that the ThreadLocal instance must be assignable to all thread instances of threads that use this thread local variable. I.e., if the instance of ThreadLocal is allocated in ScopedMemory s1, all threads using this instance must have their thread object allocated in the same or an inner scope of s1.

Method Detail

initialValue

protected T initialValue()
initialValue returns an initial value for this variable. This will be used to determine the initial value if get() is called prior to set(). This function will be invoked at most once.

The default initial value is null.

For JamaicaVM: Please note that the initial value must be assignable to all thread instances of threads that use this thread local variable. I.e., if the initial value is allocated in ScopedMemory s1, all threads using this instance must have their thread object allocated in the same or an inner scope of s1.

Returns:
the initial value for this variable.

get

public T get()
get returns the current value in the current' threads local instance of this thread local variable. This is the value that was set for this thread at the last call to set(). If the value has not been set for this thread yet, the result will be the value returned by initialValue(). In this case, the value will be set to this initialValue().

Returns:
the current value of this thread local variable.

set

public void set(T value)
set sets the current thread's value of this thread local variable to the given value.

For JamaicaVM: Please note that the value must be assignable to the current thread instance. I.e., if the value is allocated in ScopedMemory s1, then the current thread must have its thread object allocated in the same or an inner scope of s1.

ensures

   (get() == value);
 

Parameters:
value - the new value for this variable

remove

public void remove()
Remove this thread local variable (from current thread or from all threads?), reset value to initialValue.

Since:
1.5

aicas logoJamaica 6.4 release 1

aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2015 aicas GmbH. All Rights Reserved.