EDU.oswego.cs.dl.util.concurrent
public class SynchronizedDouble extends SynchronizedVariable implements java.lang.Comparable, java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
protected double |
value_ |
lock_
Constructor and Description |
---|
SynchronizedDouble(double initialValue)
Make a new SynchronizedDouble with the given initial value,
and using its own internal lock.
|
SynchronizedDouble(double initialValue,
java.lang.Object lock)
Make a new SynchronizedDouble with the given initial value,
and using the supplied lock.
|
Modifier and Type | Method and Description |
---|---|
double |
add(double amount)
Add amount to value (i.e., set value += amount)
|
boolean |
commit(double assumedValue,
double newValue)
Set value to newValue only if it is currently assumedValue.
|
int |
compareTo(double other) |
int |
compareTo(java.lang.Object other) |
int |
compareTo(SynchronizedDouble other) |
double |
divide(double factor)
Divide value by factor (i.e., set value /= factor)
|
boolean |
equals(java.lang.Object other) |
double |
get()
Return the current value
|
int |
hashCode() |
double |
multiply(double factor)
Multiply value by factor (i.e., set value *= factor)
|
double |
set(double newValue)
Set to newValue.
|
double |
subtract(double amount)
Subtract amount from value (i.e., set value -= amount)
|
double |
swap(SynchronizedDouble other)
Atomically swap values with another SynchronizedDouble.
|
java.lang.String |
toString() |
execute, getLock
public SynchronizedDouble(double initialValue)
public SynchronizedDouble(double initialValue, java.lang.Object lock)
public final double get()
public double set(double newValue)
public boolean commit(double assumedValue, double newValue)
public double swap(SynchronizedDouble other)
public double add(double amount)
public double subtract(double amount)
public double multiply(double factor)
public double divide(double factor)
public int compareTo(double other)
public int compareTo(SynchronizedDouble other)
public int compareTo(java.lang.Object other)
compareTo
in interface java.lang.Comparable
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object