Class AdvancedThreadLocal<T>

java.lang.Object
rs.baselib.util.AdvancedThreadLocal<T>

@Deprecated public class AdvancedThreadLocal<T> extends Object
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

    Constructors
    Constructor
    Description
    Deprecated.
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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.
    Deprecated.
    Removes the current thread's value for this thread-local variable.
    set(T value)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AdvancedThreadLocal

      public AdvancedThreadLocal()
      Deprecated.
      Constructor.
  • Method Details

    • initialValue

      protected T 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 the get() method, unless the thread previously invoked the set(T) method, in which case the initialValue 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 of remove() followed by get().

      This implementation simply returns null; if the programmer desires thread-local variables to have an initial value other than null, 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

      public T 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 the initialValue() method.
      Returns:
      the initial value for this thread-local
    • set

      public T set(T value)
      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 the ThreadLocal.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

      public T 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

      public Collection<Map.Entry<Thread,T>> 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.