java.lang.Object | ||
↳ | java.lang.Number | |
↳ | java.util.concurrent.atomic.AtomicInteger |
An int
value that may be updated atomically. See the
java.util.concurrent.atomic
package specification for
description of the properties of atomic variables. An
AtomicInteger
is used in applications such as atomically
incremented counters, and cannot be used as a replacement for an
Integer
. However, this class does extend
Number
to allow uniform access by tools and utilities that
deal with numerically-based classes.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new AtomicInteger with the given initial value.
| |||||||||||
Creates a new AtomicInteger with initial value
0 . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Atomically adds the given value to the current value.
| |||||||||||
Atomically sets the value to the given updated value
if the current value
== the expected value. | |||||||||||
Atomically decrements by one the current value.
| |||||||||||
Returns the value of this
AtomicInteger as a double
after a widening primitive conversion. | |||||||||||
Returns the value of this
AtomicInteger as a float
after a widening primitive conversion. | |||||||||||
Gets the current value.
| |||||||||||
Atomically adds the given value to the current value.
| |||||||||||
Atomically decrements by one the current value.
| |||||||||||
Atomically increments by one the current value.
| |||||||||||
Atomically sets to the given value and returns the old value.
| |||||||||||
Atomically increments by one the current value.
| |||||||||||
Returns the value of this
AtomicInteger as an int . | |||||||||||
Eventually sets to the given value.
| |||||||||||
Returns the value of this
AtomicInteger as a long
after a widening primitive conversion. | |||||||||||
Sets to the given value.
| |||||||||||
Returns the String representation of the current value.
| |||||||||||
Atomically sets the value to the given updated value
if the current value
== the expected value. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Number
| |||||||||||
From class
java.lang.Object
|
Creates a new AtomicInteger with the given initial value.
initialValue | the initial value |
---|
Atomically adds the given value to the current value.
delta | the value to add |
---|
Atomically sets the value to the given updated value
if the current value ==
the expected value.
expect | the expected value |
---|---|
update | the new value |
Atomically decrements by one the current value.
Returns the value of this AtomicInteger
as a double
after a widening primitive conversion.
Returns the value of this AtomicInteger
as a float
after a widening primitive conversion.
Atomically adds the given value to the current value.
delta | the value to add |
---|
Atomically decrements by one the current value.
Atomically increments by one the current value.
Atomically sets to the given value and returns the old value.
newValue | the new value |
---|
Atomically increments by one the current value.
Returns the value of this AtomicInteger
as an int
.
Eventually sets to the given value.
newValue | the new value |
---|
Returns the value of this AtomicInteger
as a long
after a widening primitive conversion.
Sets to the given value.
newValue | the new value |
---|
Returns the String representation of the current value.
Atomically sets the value to the given updated value
if the current value ==
the expected value.
May fail
spuriously and does not provide ordering guarantees, so is
only rarely an appropriate alternative to compareAndSet
.
expect | the expected value |
---|---|
update | the new value |