/** * Returns the object wrapped by this instance. On first access the object is created. After that it is cached and can * be accessed pretty fast. * * @return the object initialized by this {@code LazyInitializer} the object */ public final T get() { // use a temporary variable to reduce the number of reads of the volatile field T result = object; if (result == null) { synchronized (this) { result = object; if (result == null) { object = result = initialize(); } } } return result; }
/** * Returns the object wrapped by this instance. On first access the object is created. After that it is cached and can * be accessed pretty fast. * * @return the object initialized by this {@code LazyInitializer} the object */ public final T get() { // use a temporary variable to reduce the number of reads of the volatile field T result = object; if (result == null) { synchronized (this) { result = object; if (result == null) { object = result = initialize(); } } } return result; }
@Override protected T initialize() { return decorator.getDecoratedObject().initialize(); }
@Override protected T initialize() { return decorator.getDecoratedObject().initialize(); }