Java AtomicInteger Class

The Java AtomicInteger class is used in applications such as atomically incremented counters. This class provides operations on underlying int value that can be read and written atomically. This class contains set and get methods that work like reads and writes on volatile variables.

Java AtomicInteger Methods

SNModifier and TypeMethodDescription
1intaddAndGet(int delta)This method atomically adds the given value to the current value.
2booleancompareAndSet(int expect, int update)This method atomically sets the value to the given updated value if the current value is equal to the expected value.
3intdecrementAndGet()This method atomically decrements by one the current value.
4doubledoubleValue()This method returns the value of the specified number as a double.
5floatfloatValue()This method returns the value of the specified number as a float.
6intget()This method gets the current value.
7intgetAndAdd()This method atomically adds the given value to the current value.
8intgetAndDecrement()This method atomically decrements by one the current value.
9intgetAndSet()This method atomically sets to the given value and returns the old value.
10intincrementAndGet()This method atomically increments by one the current value.
11intgetAndIncrement()This method atomically increments by one the current value.
12intintValue()This method returns the value of the specified number as an int.
13voidlazySet(int newValue)This method Eventually sets to the given value.
14longlongValue()This method returns the value of the specified number as a long.
15voidset(int newValue)This method sets to the given value.
16StringtoString()This method returns the String representation of the current value.
17booleanweakCompareAndSet(int expect,int newValue)This method Atomically sets the value to the given updated value if the current value is equal to the expected value.





Latest Courses