java.lang.Object | ||
↳ | java.lang.Number | |
↳ | java.util.concurrent.atomic.AtomicLong |
A long
value that may be updated atomically. See the
java.util.concurrent.atomic
package specification for
description of the properties of atomic variables. An
AtomicLong
is used in applications such as atomically
incremented sequence numbers, and cannot be used as a replacement
for a Long
. 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 AtomicLong with the given initial value.
| |||||||||||
Creates a new AtomicLong 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 this object's value as a double.
| |||||||||||
Returns this object's value as a float.
| |||||||||||
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 this object's value as an int.
| |||||||||||
Returns this object's value as a long.
| |||||||||||
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 AtomicLong 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 this object's value as a double. Might involve rounding.
Returns this object's value as a float. Might involve rounding.
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 this object's value as an int. Might involve rounding and/or truncating the value, so it fits into an int.
Returns this object's value as a long. Might involve rounding and/or truncating the value, so it fits into a long.
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 |