/** * 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} * @throws ConcurrentException if an error occurred during initialization of * the object */ @Override public T get() throws ConcurrentException { // use a temporary variable to reduce the number of reads of the // volatile field T result = object; if (result == NO_INIT) { synchronized (this) { result = object; if (result == NO_INIT) { 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} * @throws ConcurrentException if an error occurred during initialization of * the object */ @Override public T get() throws ConcurrentException { // use a temporary variable to reduce the number of reads of the // volatile field T result = object; if (result == NO_INIT) { synchronized (this) { result = object; if (result == NO_INIT) { 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} * @throws ConcurrentException if an error occurred during initialization of * the object */ @Override public T get() throws ConcurrentException { // use a temporary variable to reduce the number of reads of the // volatile field T result = object; if (result == NO_INIT) { synchronized (this) { result = object; if (result == NO_INIT) { 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} * @throws ConcurrentException if an error occurred during initialization of * the object */ @Override public T get() throws ConcurrentException { // use a temporary variable to reduce the number of reads of the // volatile field T result = object; if (result == NO_INIT) { synchronized (this) { result = object; if (result == NO_INIT) { object = result = initialize(); } } } return result; }