atomic variables in java

Atomic operation

According to the techopedia “Atomic operations in concurrent programming are program operations that run completely independently of any other processes.”.

The java.util.concurrent.atomic package contains all classes that support atomic operations on single variables. All classes have methods (get and set) that work like reads and writes on volatile variables. The AtomicInteger, AtomicLong, AtomicBoolean, and AtomicReference are the most commonly used atomic variable classes in Java. These classes are used for an intlongboolean and object reference respectively.

The get() and set() are the most commonly used methods of Atomic classes where get() method is used to read value from memory same as reading a volatile variable and set() method is used to write value to memory same as writing a volatile variable.


Atomic classes examples:

Content Protection by
Please Share