Class ThreadLocals

java.lang.Object
net.hydromatic.morel.util.ThreadLocals

public class ThreadLocals extends Object
Utilities for ThreadLocal.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> void
    let(ThreadLocal<T> threadLocal, T value, Runnable runnable)
    Performs an action with a thread-local set to a particular value.
    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.
    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.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ThreadLocals

      private ThreadLocals()
  • Method Details

    • 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.