public abstract class ThreadGroupLocal
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
cleanup()
Cleanup all storage associated with the effective ThreadGroup's
ThreadGroupLocal storage.
|
static java.lang.Object |
get(java.lang.Object key)
Get the value for the key for the current ThreadGroup
|
static java.lang.ThreadGroup |
getThreadProxyGroup()
Get this thread's proxy group.
|
static java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Set the key value pair for the current ThreadGroup
|
static java.lang.Object |
remove(java.lang.Object key)
Remove the key and associated value for the specified ThreadGroup
|
static void |
removeAll()
Remove all keys and associated value for the current ThreadGroup
|
static java.lang.ThreadGroup |
setThreadProxyGroup(java.lang.ThreadGroup proxy)
Set this thread's proxy group.
|
public static java.lang.ThreadGroup getThreadProxyGroup()
setThreadProxyGroup(java.lang.ThreadGroup)
public static java.lang.ThreadGroup setThreadProxyGroup(java.lang.ThreadGroup proxy)
A proxy ThreadGroup is useful if your code is called on a thread over which you have no control (and may not have been created in the same ThreadGroup as other threads that need to put and get shared variables.
To use a proxy group, do the following:
...
ThreadGroup oldProxy = ThreadGroupLocal.setThreadProxyGroup(proxyGroup);
...
//get variable values using ThreadGroupLocal.get()
...
ThreadGroupLocal.setThreadProxyGroup(oldProxy);
...
Note that the DirXML Subscriber and Publisher threads are members of the same ThreadGroup.
proxy
- The ThreadGroup to use instead of the current Thread's actual ThreadGrouppublic static java.lang.Object put(java.lang.Object key, java.lang.Object value)
key
- value
- null
otherwisepublic static java.lang.Object get(java.lang.Object key)
key
- null
otherwisepublic static java.lang.Object remove(java.lang.Object key)
key
- null
otherwisepublic static void removeAll()
public static void cleanup()