com.groiss.ds
Class ThreadLocal2

java.lang.Object
  extended by java.lang.ThreadLocal
      extended by com.groiss.ds.ThreadLocal2

public class ThreadLocal2
extends java.lang.ThreadLocal

Same as java.lang.ThreadLocal, plus monitoring utility


Constructor Summary
ThreadLocal2()
          Creates a ThreadLocal variable.
 
Method Summary
 java.lang.Object get()
          Returns the value in the calling thread's copy of this ThreadLocal variable.
 java.util.HashMap getThreads()
          Returns the HashMap, keys are the threads
protected  java.lang.Object initialValue()
          Returns the calling thread's initial value for this ThreadLocal variable.
 void set(java.lang.Object value)
          Sets the calling thread's instance of this ThreadLocal variable to the given value.
 
Methods inherited from class java.lang.ThreadLocal
remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadLocal2

public ThreadLocal2()
Creates a ThreadLocal variable.

Method Detail

initialValue

protected java.lang.Object initialValue()
Returns the calling thread's initial value for this ThreadLocal variable. This method will be called once per accessing thread for each ThreadLocal, the first time each thread accesses the variable with get or set. If the programmer desires ThreadLocal variables to be initialized to some value other than null, ThreadLocal must be subclassed, and this method overridden. Typically, an anonymous inner class will be used. Typical implementations of initialValue will call an appropriate constructor and return the newly constructed object.

Overrides:
initialValue in class java.lang.ThreadLocal
Returns:
the initial value for this ThreadLocal

get

public java.lang.Object get()
Returns the value in the calling thread's copy of this ThreadLocal variable. Creates and initializes the copy if this is the first time the thread has called this method.

Overrides:
get in class java.lang.ThreadLocal
Returns:
the value of this ThreadLocal

set

public void set(java.lang.Object value)
Sets the calling thread's instance of this ThreadLocal variable to the given value. This is only used to change the value from the one assigned by the initialValue method, and many applications will have no need for this functionality.

Overrides:
set in class java.lang.ThreadLocal
Parameters:
value - the value to be stored in the calling threads' copy of this ThreadLocal.

getThreads

public java.util.HashMap getThreads()
Returns the HashMap, keys are the threads

Returns:
the HashMap of values


Copyright © 2001-2006 Groiss Informatics GmbH. All Rights Reserved.