AtomicInteger - zhamri/MyClass-STIW3054 GitHub Wiki

Why use AtomicInteger?

The primary use of AtomicInteger is when we are in multi-threaded context and we need to perform atomic operations on an int value without using synchronized keyword.

Advantage:

Using the AtomicInteger is equally faster and more readable than performing the same using synchronization.

References:

  1. https://docs.oracle.com/javase/tutorial/essential/concurrency/atomicvars.html
  2. http://tutorials.jenkov.com/java-util-concurrent/atomicinteger.html
  3. https://howtodoinjava.com/java/multi-threading/atomicinteger-example/
  4. https://www.javatpoint.com/java-atomicinteger-compareandset-method