public class AtomicFloat
extends java.lang.Number
implements java.io.Serializable
AtomicInteger
.)
For example, an atomic float might be used for parallel computation of the
dot product of two vectors of floats.Constructor and Description |
---|
AtomicFloat()
Constructs an atomic float with initial value zero.
|
AtomicFloat(float value)
Constructs an atomic float with specified initial value.
|
Modifier and Type | Method and Description |
---|---|
float |
addAndGet(float delta)
Atomically adds a specified value to the value of this float.
|
boolean |
compareAndSet(float expect,
float update)
Atomically sets this float to the specified updated value
if the current value equals the specified expected value.
|
float |
decrementAndGet()
Atomically decrements by one the value of this float.
|
double |
doubleValue() |
float |
floatValue() |
float |
get()
Gets the current value of this float.
|
float |
getAndAdd(float delta)
Atomically adds a specified value to the value of this float.
|
float |
getAndDecrement()
Atomically decrements by one the value of this float.
|
float |
getAndIncrement()
Atomically increments by one the value of this float.
|
float |
getAndSet(float value)
Atomically sets the value of this float and returns its old value.
|
float |
incrementAndGet()
Atomically increments by one the value of this float.
|
int |
intValue() |
long |
longValue() |
void |
set(float value)
Sets the value of this float.
|
java.lang.String |
toString() |
boolean |
weakCompareAndSet(float expect,
float update)
Atomically sets this float to the specified updated value
if the current value equals the specified expected value.
|
public AtomicFloat()
public AtomicFloat(float value)
value
- the initial value.public final float get()
public final void set(float value)
value
- the new value.public final float getAndSet(float value)
value
- the new value.public final boolean compareAndSet(float expect, float update)
expect
- the expected value.update
- the updated value.public final boolean weakCompareAndSet(float expect, float update)
My fail spuriously, and does not provide ordering guarantees, so is only rarely useful.
expect
- the expected value.update
- the updated value.public final float getAndIncrement()
public final float getAndDecrement()
public final float getAndAdd(float delta)
delta
- the value to add.public final float incrementAndGet()
public final float decrementAndGet()
public final float addAndGet(float delta)
delta
- the value to add.public java.lang.String toString()
toString
in class java.lang.Object
public int intValue()
intValue
in class java.lang.Number
public long longValue()
longValue
in class java.lang.Number
public float floatValue()
floatValue
in class java.lang.Number
public double doubleValue()
doubleValue
in class java.lang.Number