Class ThreadAssocStore
- java.lang.Object
-
- hudson.plugins.project_inheritance.util.ThreadAssocStore
-
public class ThreadAssocStore extends Object
This singleton class is used to associated arbitrary objects with the current thread.It is a singleton to ensure static access from all corners of the application. It can be used as a crude way to communicate across methods in the same call stack.
Simply think of it as a way to store thread-global object references. The content will be removed after the thread ends. If you need earlier release, just overwrite the values with a null.
Do note that this class will purge the map from dead threads every minutes as long as threads are being added. This is done to prevent the held Threads from not being garbage-collected.
- Author:
- Martin Schroeder
-
-
Constructor Summary
Constructors Constructor Description ThreadAssocStore()
Constructor used by the Extension annotation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup()
void
clear(String key)
void
clear(Thread t)
void
clear(Thread t, String key)
static ThreadAssocStore
getInstance()
Object
getValue(String key)
Object
getValue(Thread t, String key)
void
setValue(String key, Object value)
void
setValue(Thread t, String key, Object value)
-
-
-
Constructor Detail
-
ThreadAssocStore
public ThreadAssocStore()
Constructor used by the Extension annotation.You should not need to spawn a
ThreadAssocStore
yourself. Instead, usegetInstance()
to get the singleton.
-
-
Method Detail
-
getInstance
public static final ThreadAssocStore getInstance()
-
cleanup
public void cleanup()
-
clear
public void clear(Thread t)
-
clear
public void clear(String key)
-
-