public class LongMaxUpdater extends Number implements Serializable
long
maximum with initial value Long.MIN_VALUE
. When updates
(method update(long)
) are contended across threads, the set of
variables may grow dynamically to reduce contention. Method max()
(or, equivalently, longValue()
) returns the current
maximum across the variables maintaining updates.
This class extends Number
, but does not define
methods such as equals
, hashCode
and compareTo
because instances are expected to be mutated, and so are
not useful as collection keys.
jsr166e note: This class is targeted to be placed in java.util.concurrent.atomic.
Constructor and Description |
---|
LongMaxUpdater()
Creates a new instance with initial maximum of
Long.MIN_VALUE . |
Modifier and Type | Method and Description |
---|---|
double |
doubleValue()
Returns the
max() as a double after a widening
primitive conversion. |
float |
floatValue()
Returns the
max() as a float
after a widening primitive conversion. |
int |
intValue()
Returns the
max() as an int after a narrowing
primitive conversion. |
long |
longValue()
Equivalent to
max() . |
long |
max()
Returns the current maximum.
|
long |
maxThenReset()
|
void |
reset()
Resets variables maintaining updates to
Long.MIN_VALUE . |
String |
toString()
Returns the String representation of the
max() . |
void |
update(long x)
Updates the maximum to be at least the given value.
|
byteValue, shortValue
public LongMaxUpdater()
Long.MIN_VALUE
.public void update(long x)
x
- the value to updatepublic long max()
public void reset()
Long.MIN_VALUE
.
This method may be a useful alternative to creating a new
updater, but is only effective if there are no concurrent
updates. Because this method is intrinsically racy, it should
only be used when it is known that no threads are concurrently
updating.public long maxThenReset()
max()
followed by reset()
. This method may apply for example during quiescent
points between multithreaded computations. If there are
updates concurrent with this method, the returned value is
not guaranteed to be the final value occurring before
the reset.public long longValue()
max()
.public int intValue()
max()
as an int
after a narrowing
primitive conversion.public float floatValue()
max()
as a float
after a widening primitive conversion.floatValue
in class Number
public double doubleValue()
max()
as a double
after a widening
primitive conversion.doubleValue
in class Number
Copyright © 2009–2015. All rights reserved.