Package w.util.lazy

Class ConcurrentLazy<T>

java.lang.Object
w.util.lazy.ConcurrentLazy<T>
All Implemented Interfaces:
Supplier<T>, Lazy<T>

public final class ConcurrentLazy<T> extends Object implements Lazy<T>
Потоко-безопасная реализация Lazy, которая гарантированно инициализирует значение только один раз,

Если вы используете Lazy.clear() и Supplier.get(), то некоторые потоки могут вернуть старое значение.

Author:
whilein
  • Constructor Details

    • ConcurrentLazy

      public ConcurrentLazy()
  • Method Details

    • create

      @NotNull public static <T> @NotNull Lazy<T> create(@NotNull @NotNull Supplier<T> supplier, @NotNull @NotNull Object mutex)
    • create

      @NotNull public static <T> @NotNull Lazy<T> create(@NotNull @NotNull Supplier<T> supplier)
    • clear

      public void clear()
      Description copied from interface: Lazy
      Очистить сохраненное значение
      Specified by:
      clear in interface Lazy<T>
    • clearAndGet

      public T clearAndGet()
      Description copied from interface: Lazy
      Очистить и получить новое значение
      Specified by:
      clearAndGet in interface Lazy<T>
      Returns:
      новое значение
    • get

      public T get()
      Specified by:
      get in interface Supplier<T>