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 the value of this
AtomicLong as a double
after a widening primitive conversion. | |||||||||||
Returns the value of this
AtomicLong 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
AtomicLong as an int
after a narrowing primitive conversion. | |||||||||||
Eventually sets to the given value.
| |||||||||||
Returns the value of this
AtomicLong 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 the value of this AtomicLong
as a double
after a widening primitive conversion.
Returns the value of this AtomicLong
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 AtomicLong
as an int
after a narrowing primitive conversion.
Eventually sets to the given value.
newValue | the new value |
---|
Returns the value of this AtomicLong
as 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 |