Class DetachedThreadLocal<T>
java.lang.Object
org.mockito.internal.util.concurrent.DetachedThreadLocal<T>
- All Implemented Interfaces:
Runnable
A detached local that allows for explicit control of setting and removing values from a thread-local context.
Instances of this class are non-blocking and fully thread safe.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Determines the cleaning format. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
void
clearAll()
Clears all thread local references for all threads.void
get()
protected T
inheritValue
(T value) protected T
initialValue
(Thread thread) void
run()
void
-
Field Details
-
map
-
-
Constructor Details
-
DetachedThreadLocal
-
-
Method Details
-
get
-
get
- Parameters:
thread
- The thread for which to set a thread-local value.- Returns:
- The value associated with this thread.
-
set
-
clear
public void clear() -
clearAll
public void clearAll()Clears all thread local references for all threads. -
pushTo
- Parameters:
thread
- The thread to which this thread's thread local value should be pushed.- Returns:
- The value being set.
-
fetchFrom
- Parameters:
thread
- The thread from which the thread thread local value should be fetched.- Returns:
- The value being set.
-
define
- Parameters:
thread
- The thread for which to set a thread-local value.value
- The value to set.
-
initialValue
- Parameters:
thread
- The thread for which an initial value is created.- Returns:
- The initial value for any thread local. If no default is set, the default value is
null
.
-
inheritValue
- Parameters:
value
- The value that is inherited.- Returns:
- The inherited value.
-
getBackingMap
- Returns:
- The weak map that backs this detached thread local.
-
run
public void run()
-