/** * Returns the object managed by this initializer. The object is created if * it is not available yet and stored internally. This method always returns * the same object. * * @return the object created by this {@code AtomicInitializer} * @throws ConcurrentException if an error occurred during initialization of * the object */ @Override public T get() throws ConcurrentException { T result = reference.get(); if (result == null) { result = initialize(); if (!reference.compareAndSet(null, result)) { // another thread has initialized the reference result = reference.get(); } } return result; }
/** * Returns the object managed by this initializer. The object is created if * it is not available yet and stored internally. This method always returns * the same object. * * @return the object created by this {@code AtomicInitializer} * @throws ConcurrentException if an error occurred during initialization of * the object */ @Override public T get() throws ConcurrentException { T result = reference.get(); if (result == null) { result = initialize(); if (!reference.compareAndSet(null, result)) { // another thread has initialized the reference result = reference.get(); } } return result; }
/** * Returns the object managed by this initializer. The object is created if * it is not available yet and stored internally. This method always returns * the same object. * * @return the object created by this {@code AtomicInitializer} * @throws ConcurrentException if an error occurred during initialization of * the object */ @Override public T get() throws ConcurrentException { T result = reference.get(); if (result == null) { result = initialize(); if (!reference.compareAndSet(null, result)) { // another thread has initialized the reference result = reference.get(); } } return result; }
/** * Returns the object managed by this initializer. The object is created if * it is not available yet and stored internally. This method always returns * the same object. * * @return the object created by this {@code AtomicInitializer} * @throws ConcurrentException if an error occurred during initialization of * the object */ @Override public T get() throws ConcurrentException { T result = reference.get(); if (result == null) { result = initialize(); if (!reference.compareAndSet(null, result)) { // another thread has initialized the reference result = reference.get(); } } return result; }