AtomicInteger
class AtomicInteger
An AtomicInteger is a int value that need to be updated atomically, see java.util.concurrent.atomic package to view atomic specifications.
public class AtomicInteger
— Constructors (2) —
| Constructor | Description |
|---|---|
| AtomicInteger() | Creates a new AtomicInteger with the default value set to 0. |
| AtomicInteger(int value) | Creates a new AtomicInteger with the default value set to be "value" argument. |
— Methods (12) —
| Name | Description |
|---|---|
| int get() | Return the current int value. |
| void set(int value) | Set the current value to be "value" argument. |
| void lazySet(int value) | set the current int value to be "value" argument at any time. |
| boolean compareAndSet(int expected, int update) | If the current value is equal to "expected" argument, the current value will be set to be "update" argument. |
| boolean weakCompareAndSet(int expected, int update) | If the current value is equal to "expected" argument, the current value will be set to be "update" argument. |
| int getAndSet(int value) | Return the current int value and set to be "value" argument. |
| int getAndIncrement() | Return the current int value and increment the current value by one. |
| int getAndDecrement() | Return the current int value and decrement the current value by one. |
| int incrementAndGet() | Increment the current value by one and returns the current value. |
| int decrementAndGet() | Decrement the current value by one and returns the current value. |
| int getAndAdd(int value) | Returns the current value and adds to be "value" argument. |
| int addAndGet(int value) | Adds the value to be "value" argument, and returns the current value. |