T - the type of the referenced object.public class LazyAtomicReference<T>
extends java.lang.Object
| Constructor and Description |
|---|
LazyAtomicReference(java.util.concurrent.Callable<T> initializer)
Create an atomic that will be lazily initialized if get is invoked before set.
|
| Modifier and Type | Method and Description |
|---|---|
T |
get()
Get the value of the atomic.
|
void |
set(T newValue)
Set the value of the atomic.
|
public LazyAtomicReference(java.util.concurrent.Callable<T> initializer)
initializer - the lazy initializer. The initializer is only invoked if a client class attempts
to get the value before it has been set. The initializer must not return null and must not invoke
methods on the instance it is initializing.public T get()
java.lang.NullPointerException - - the initializer was invoked but returned null; internal error.java.lang.RuntimeException - - wraps any exception thrown in the initializer; internal error.public void set(T newValue)
newValue - the value. May not be null.