Java – AtomicReference Class

Java AtomicReference Class methods, constructors, variables available in Java 8 release are listed below. We will publish example program on each methods ASAP.

Constructors in Java AtomicReference Class

S.No Constructor & Description
1 AtomicReference()

Creates a new AtomicReference with null initial value.
2 AtomicReference(V initialValue)

Creates a new AtomicReference with the given initial value.

Methods in Java AtomicReference Class

S.No Method & Description
1 V accumulateAndGet(V x, BinaryOperator<V> accumulatorFunction)

Atomically updates the current value with the results of applying the given function to the current and given values, returning the updated value.
2 boolean compareAndSet(V expect, V update)

Atomically sets the value to the given updated value if the current value == the expected value.
3 V get()

Gets the current value.
4 V getAndAccumulate(V x, BinaryOperator<V> accumulatorFunction)

Atomically updates the current value with the results of applying the given function to the current and given values, returning the previous value.
5 V getAndSet(V newValue)

Atomically sets to the given value and returns the old value.
6 V getAndUpdate(UnaryOperator<V> updateFunction)

Atomically updates the current value with the results of applying the given function, returning the previous value.
7 void lazySet(V newValue)

Eventually sets to the given value.
8 void set(V newValue)

Sets to the given value.
9 String toString()

Returns the String representation of the current value.
10 V updateAndGet(UnaryOperator<V> updateFunction)

Atomically updates the current value with the results of applying the given function, returning the updated value.
11 boolean weakCompareAndSet(V expect, V update)

Atomically sets the value to the given updated value if the current value == the expected value.

Ask your questions in eHowToNow Forum

Post your technical, non-technical doubts, questions in our site. Get answer as soon as possible, meanwhile you can help others by answering, unanswered questions.
To Ask new Question : Ask Question
Check our existing discussions : Questions & Answers

  1. Java – AtomicStampedReference Class
  2. Java – AtomicLongArray Class
  3. Java – AtomicReference Class
  4. Java – AtomicIntegerFieldUpdater Class
  5. Java – AtomicReferenceArray Class
  6. java.util.concurrent.atomic Package
  7. Java – DoubleAdder Class
  8. Java – DoubleAccumulator Class
  9. Java – AtomicBoolean Class
  10. Java – LongAccumulator Class
  11. Java – AtomicIntegerArray Class
  12. Java – AtomicReferenceFieldUpdater Class
  13. Java – AtomicMarkableReference Class
  14. Java – AtomicLongFieldUpdater Class
  15. Java – AtomicLong Class

Be the first to comment

Leave a Reply