Package com.gengoai.concurrent
Class AtomicDouble
- java.lang.Object
-
- java.lang.Number
-
- com.gengoai.concurrent.AtomicDouble
-
- All Implemented Interfaces:
Serializable
public class AtomicDouble extends Number
Thread safe double container
- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AtomicDouble()
Instantiates a new Atomic double.AtomicDouble(double value)
Instantiates a new Atomic double.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
addAndGet(double value)
Atomically adds the given value to the current value.boolean
compareAndSet(double expect, double update)
Atomically sets the value to the given updated value if the current value==
the expected value.double
doubleValue()
float
floatValue()
double
get()
Gets the double valuedouble
getAndAdd(double value)
Atomically adds the given value to the current value.double
getAndSet(double value)
Atomically sets to the given value and returns the old value.int
intValue()
long
longValue()
void
set(double value)
Sets to the given value.String
toString()
boolean
weakCompareAndSet(double expect, double update)
Atomically sets the value to the given updated value if the current value == the expected value.-
Methods inherited from class java.lang.Number
byteValue, shortValue
-
-
-
-
Method Detail
-
addAndGet
public final double addAndGet(double value)
Atomically adds the given value to the current value.- Parameters:
value
- the value- Returns:
- the updated value
-
compareAndSet
public final boolean compareAndSet(double expect, double update)
Atomically sets the value to the given updated value if the current value==
the expected value.- Parameters:
expect
- the expected valueupdate
- the new value- Returns:
true
if successful. False return indicates that the actual value was not equal to the expected value.
-
doubleValue
public double doubleValue()
- Specified by:
doubleValue
in classNumber
-
floatValue
public float floatValue()
- Specified by:
floatValue
in classNumber
-
get
public double get()
Gets the double value- Returns:
- the double
-
getAndAdd
public final double getAndAdd(double value)
Atomically adds the given value to the current value.- Parameters:
value
- the value- Returns:
- the previous value
-
getAndSet
public double getAndSet(double value)
Atomically sets to the given value and returns the old value.- Parameters:
value
- the value to set- Returns:
- the value before the update
-
set
public void set(double value)
Sets to the given value.- Parameters:
value
- the value
-
weakCompareAndSet
public final boolean weakCompareAndSet(double expect, double update)
Atomically sets the value to the given updated value if the current value == the expected value.- Parameters:
expect
- the expected valueupdate
- the updated value- Returns:
- True if updated, False if not
-
-