Package rs.baselib.util
Class AdvancedThreadLocal<T>
java.lang.Object
rs.baselib.util.AdvancedThreadLocal<T>
Deprecated.
Extends functionality of
ThreadLocal
by allowing to access
values from other threads.
The need comes from threads that leave behind resources, however cannot detect the problem themselfs.
- Since:
- 1.2.9
- Author:
- ralph
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Deprecated.Clears all values on all threads.get()
Deprecated.Returns the value in the current thread's copy of this thread-local variable.Deprecated.Returns the current values of this set.protected T
Deprecated.Returns the current thread's "initial value" for this thread-local variable.remove()
Deprecated.Removes the current thread's value for this thread-local variable.Deprecated.Sets the current thread's copy of this thread-local variable to the specified value.void
Deprecated.Removes all values where the thried died meanwhile.
-
Constructor Details
-
AdvancedThreadLocal
public AdvancedThreadLocal()Deprecated.Constructor.
-
-
Method Details
-
initialValue
Deprecated.Returns the current thread's "initial value" for this thread-local variable. This method will be invoked the first time a thread accesses the variable with theget()
method, unless the thread previously invoked theset(T)
method, in which case theinitialValue
method will not be invoked for the thread. Normally, this method is invoked at most once per thread, but it may be invoked again in case of subsequent invocations ofremove()
followed byget()
.This implementation simply returns
null
; if the programmer desires thread-local variables to have an initial value other thannull
,ThreadLocal
must be subclassed, and this method overridden. Typically, an anonymous inner class will be used.- Returns:
- the initial value for this thread-local
-
get
Deprecated.Returns the value in the current thread's copy of this thread-local variable. If the variable has no value for the current thread, it is first initialized to the value returned by an invocation of theinitialValue()
method.- Returns:
- the initial value for this thread-local
-
set
Deprecated.Sets the current thread's copy of this thread-local variable to the specified value. Most subclasses will have no need to override this method, relying solely on theThreadLocal.initialValue()
method to set the values of thread-locals.- Parameters:
value
- the value to be stored in the current thread's copy of this thread-local.- Returns:
- the old value
- See Also:
-
remove
Deprecated.Removes the current thread's value for this thread-local variable. If this thread-local variable is subsequently read by the current thread, its value will be reinitialized by invoking its initialValue method, unless its value is set by the current thread in the interim. This may result in multiple invocations of the initialValue method in the current thread.- Returns:
- value removed
- See Also:
-
getEntries
Deprecated.Returns the current values of this set.- Returns:
- the current values
-
verifyThreads
public void verifyThreads()Deprecated.Removes all values where the thried died meanwhile. -
clear
public void clear()Deprecated.Clears all values on all threads.
-