Package net.sf.ehcache.util.lang
Class VicariousThreadLocal<T>
- java.lang.Object
-
- java.lang.ThreadLocal<T>
-
- net.sf.ehcache.util.lang.VicariousThreadLocal<T>
-
public class VicariousThreadLocal<T> extends java.lang.ThreadLocal<T>A drop-in replacementThreadLocalimplementation that does not leak when thread-local values reference theThreadLocalobject. The code is optimised to cope with frequently changing values.In comparison to plain
ThreadLocal, this implementation:- from the point of view of a single thread, each thread-local {code #get} requires access to four objects instead of two
- is fractionally slower in terms of CPU cycles for {code #get}
- uses around twice the memory for each thead-local value
- uses around four times the memory for each
ThreadLocal - may release thread-local values for garbage collection more promptly
-
-
Constructor Summary
Constructors Constructor Description VicariousThreadLocal()Creates a newVicariousThreadLocal.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tget()voidpoll()Check if any strong references need should be removed due to thread exit.voidremove()voidset(T value)
-
-
-
Method Detail
-
remove
public void remove()
- Overrides:
removein classjava.lang.ThreadLocal<T>
-
poll
public void poll()
Check if any strong references need should be removed due to thread exit.
-
-