T - public class VicariousThreadLocal<T>
extends java.lang.ThreadLocal<T>
ThreadLocal implementation that does not leak
when thread-local values reference the ThreadLocal object.
The code is optimised to cope with frequently changing values.
In comparison to plain ThreadLocal, this implementation:
ThreadLocal
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
VERSION |
| Constructor and Description |
|---|
VicariousThreadLocal()
Creates a new
VicariousThreadLocal. |
| Modifier and Type | Method and Description |
|---|---|
<R> R |
callWith(T value,
java.util.concurrent.Callable<R> doCall)
Executes task with thread-local set to the specified value.
|
T |
get() |
boolean |
isInitialized()
Indicates whether thread-local has been initialised for the current thread.
|
static <T> VicariousThreadLocal<T> |
newThreadLocal()
Creates a new
VicariousThreadLocal. |
static <T> VicariousThreadLocal<T> |
newThreadLocal(java.util.concurrent.Callable<T> doCall)
Creates a new
VicariousThreadLocal
with initial value from Callable. |
static <T> VicariousThreadLocal<T> |
newThreadLocal(T initialValue)
Creates a new
VicariousThreadLocal with specified initial value. |
void |
poll()
Check if any strong references need should be removed due to thread exit.
|
void |
remove() |
void |
runWith(T value,
java.lang.Runnable doRun)
Executes task with thread-local set to the specified value.
|
void |
set(T value) |
T |
swap(T value)
Swaps the current threads value with the supplied value.
|
public VicariousThreadLocal()
VicariousThreadLocal.public static <T> VicariousThreadLocal<T> newThreadLocal()
VicariousThreadLocal.public static <T> VicariousThreadLocal<T> newThreadLocal(T initialValue)
VicariousThreadLocal with specified initial value.initialValue - public static <T> VicariousThreadLocal<T> newThreadLocal(java.util.concurrent.Callable<T> doCall)
VicariousThreadLocal
with initial value from Callable.doCall - public void remove()
remove in class java.lang.ThreadLocal<T>public boolean isInitialized()
public T swap(T value)
value - public void runWith(T value, java.lang.Runnable doRun)
value - doRun - public <R> R callWith(T value, java.util.concurrent.Callable<R> doCall) throws java.lang.Exception
value - doCall - doCalljava.lang.Exceptionpublic void poll()
Copyright © 2014 Pegasystems Inc. All Rights Reserved.