public class XLazy<T,X extends Exception> extends Object implements XSupplier<T,X>
XSupplier that provides a virtually fixed value.
This value is only actually determined when it is accessed for the first time.
This implementation ensures that the originally defined initialization code is called at most once, even if there is concurrent access from multiple threads, unless the initialization attempt causes an exception.
Once the value is established, unnecessary effort to synchronize competing accesses is avoided.
| Constructor and Description |
|---|
XLazy(XSupplier<T,X> initial)
Initializes a new instance giving a supplier that defines the intended initialization of the
represented value.
|
| Modifier and Type | Method and Description |
|---|---|
T |
get()
Executes the originally defined initialization code on the first call and
returns its result on that and every subsequent call without calling the supplier again.
|
public final T get() throws X extends Exception
Copyright © 2022 Andreas Kluge-Kaindl, Bremen (de). All rights reserved.