Package net.hydromatic.morel.util
Class ThreadLocals
- java.lang.Object
-
- net.hydromatic.morel.util.ThreadLocals
-
public class ThreadLocals extends Object
Utilities forThreadLocal.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateThreadLocals()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> voidlet(ThreadLocal<T> threadLocal, T value, Runnable runnable)Performs an action with a thread-local set to a particular value.static <T,R>
Rlet(ThreadLocal<T> threadLocal, T value, Supplier<R> supplier)Performs an action with a thread-local set to a particular value, and returns the result.static <T> voidmutate(ThreadLocal<T> threadLocal, UnaryOperator<T> transform, Runnable runnable)Performs an action with a thread-local set to a value derived from its current value via a transformer.static <T,R>
Rmutate(ThreadLocal<T> threadLocal, UnaryOperator<T> transform, Supplier<R> supplier)Performs an action with a thread-local set to a value derived from its current value via a transformer, and returns the result.
-
-
-
Method Detail
-
let
public static <T> void let(ThreadLocal<T> threadLocal, T value, Runnable runnable)
Performs an action with a thread-local set to a particular value.
-
let
public static <T,R> R let(ThreadLocal<T> threadLocal, T value, Supplier<R> supplier)
Performs an action with a thread-local set to a particular value, and returns the result.
-
mutate
public static <T> void mutate(ThreadLocal<T> threadLocal, UnaryOperator<T> transform, Runnable runnable)
Performs an action with a thread-local set to a value derived from its current value via a transformer.
-
mutate
public static <T,R> R mutate(ThreadLocal<T> threadLocal, UnaryOperator<T> transform, Supplier<R> supplier)
Performs an action with a thread-local set to a value derived from its current value via a transformer, and returns the result.
-
-