public class AtomicDoubleArray extends Object implements Serializable
AtomicLongArray
. As such, the methods have the same documentationConstructor and Description |
---|
AtomicDoubleArray(double[] array)
Creates a new AtomixDouble Array that is of the same length
as the input array.
|
AtomicDoubleArray(int length)
Creates a new AtomicDoubleArray of the given length, with all values
initialized to zero
|
Modifier and Type | Method and Description |
---|---|
double |
addAndGet(int i,
double delta)
Atomically adds the given value to the element at index
i . |
boolean |
compareAndSet(int i,
double expected,
double update)
Atomically sets the element at position
i to the given
updated value if the current value == the expected value. |
double |
get(int i)
Gets the current value at position
i . |
double |
getAndAdd(int i,
double delta)
Atomically adds the given value to the element at index
i . |
double |
getAndDecrement(int i)
Atomically decrements by one the element at index
i . |
double |
getAndIncrement(int i)
Atomically increments by one the element at index
i . |
double |
getAndSet(int i,
double newValue)
Atomically sets the element at position
i to the given value
and returns the old value. |
void |
lazySet(int i,
double newValue)
Eventually sets the element at position
i to the given value. |
int |
length()
Returns the length of the array.
|
void |
set(int i,
double newValue)
Sets the element at position
i to the given value. |
boolean |
weakCompareAndSet(int i,
double expected,
double update)
Atomically sets the element at position
i to the given
updated value if the current value == the expected value. |
public AtomicDoubleArray(int length)
length
- the length of the arraypublic AtomicDoubleArray(double[] array)
array
- the array of values to copypublic double getAndIncrement(int i)
i
.i
- the indexpublic double getAndDecrement(int i)
i
.i
- the indexpublic double getAndAdd(int i, double delta)
i
.i
- the indexdelta
- the value to addpublic double addAndGet(int i, double delta)
i
.i
- the indexdelta
- the value to addpublic double getAndSet(int i, double newValue)
i
to the given value
and returns the old value.i
- the indexnewValue
- the new valuepublic void set(int i, double newValue)
i
to the given value.i
- the indexnewValue
- the new valuepublic void lazySet(int i, double newValue)
i
to the given value.i
- the indexnewValue
- the new valuepublic boolean compareAndSet(int i, double expected, double update)
i
to the given
updated value if the current value ==
the expected value.i
- the indexexpected
- the expected valueupdate
- the new valuepublic boolean weakCompareAndSet(int i, double expected, double update)
i
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
.
i
- the indexexpected
- the expected valueupdate
- the new valuepublic double get(int i)
i
.i
- the indexpublic int length()
Copyright © 2017. All rights reserved.