Atomic Variables Flashcards
Atomically updatable boolean value.
java.util.concurrent.atomic.AtomicBoolean
Atomically updatable int value, extends Number class
java.util.concurrent.atomic.AtomicInteger
An int array in which elements can be updated atomically.
java.util.concurrent.atomic.AtomicIntegerArray
Atomically updatable long value, extends Number class.
java.util.concurrent.atomic.AtomicLong
A long array in which elements can be updated atomically.
java.util.concurrent.atomic.AtomicLongArray
An atomically updatable object reference of type V
java.util.concurrent.atomic.AtomicReference
An atomically updatabale object array that can hold references of type E.
java.util.concurrent.atomic.AtomicReferenceArray
Constructor that creates an instance of AtomicInteger with initial value 0.
AtomicInteger()
Overloaded constructor of AtomicInteger that creates it with an initial value set by initVal
AtomicInteger(int initVal)
Returns the value held by the object.
int get()
Resets the integer value held in this object to newVal.
void set(int newVal)
Returns the current int value held in this object and sets the value held in this object to newVal.
int getAndSet(int newValue)
Compares the int value of this object to the expect value, and if they are equal, sets the int value of this object to the update value.
boolean compareAndSet(int expect, int update)
Returns the current value of the integer value in this object and increments the integer value in this object. Atomic version of i++.
int getAndIncrement()
Returns the current value of the integer value in this object and decrements the integer value in this object. Atomic version of iā
int getAndDecrement()