Class ThreadSafeLazyValue<T>

java.lang.Object
dev.getelements.elements.sdk.util.ThreadSafeLazyValue<T>
Type Parameters:
T - the type of value to supply
All Implemented Interfaces:
LazyValue<T>, Supplier<T>

public class ThreadSafeLazyValue<T> extends Object implements LazyValue<T>
A thread-safe implementation of SimpleLazyValue. This uses a Lock to perform the synchronization.
  • Constructor Details

    • ThreadSafeLazyValue

      public ThreadSafeLazyValue(Supplier<T> tSupplier)
      Creates an instance of ThreadSafeLazyValue<T> with default lock. This constructor uses the constructor ReentrantLock() to construct the lock using the default fairness option.
      Parameters:
      tSupplier - the Supplier<T> which supplies the value.
    • ThreadSafeLazyValue

      public ThreadSafeLazyValue(Supplier<T> tSupplier, Lock lock)
      Creates an instance of ThreadSafeLazyValue<T> with default lock. This constructor allows for the specification of a custom Lock instance.
      Parameters:
      tSupplier - the Supplier<T> which supplies the value.
  • Method Details