EDU.oswego.cs.dl.util.concurrent
public class SynchronizedLong extends SynchronizedVariable implements java.lang.Comparable, java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
protected long |
value_ |
lock_
Constructor and Description |
---|
SynchronizedLong(long initialValue)
Make a new SynchronizedLong with the given initial value,
and using its own internal lock.
|
SynchronizedLong(long initialValue,
java.lang.Object lock)
Make a new SynchronizedLong with the given initial value,
and using the supplied lock.
|
Modifier and Type | Method and Description |
---|---|
long |
add(long amount)
Add amount to value (i.e., set value += amount)
|
long |
and(long b)
Set value to value & b.
|
boolean |
commit(long assumedValue,
long newValue)
Set value to newValue only if it is currently assumedValue.
|
int |
compareTo(long other) |
int |
compareTo(java.lang.Object other) |
int |
compareTo(SynchronizedLong other) |
long |
complement()
Set the value to its complement
|
long |
decrement()
Decrement the value.
|
long |
divide(long factor)
Divide value by factor (i.e., set value /= factor)
|
boolean |
equals(java.lang.Object other) |
long |
get()
Return the current value
|
int |
hashCode() |
long |
increment()
Increment the value.
|
long |
multiply(long factor)
Multiply value by factor (i.e., set value *= factor)
|
long |
negate()
Set the value to the negative of its old value
|
long |
or(long b)
Set value to value | b.
|
long |
set(long newValue)
Set to newValue.
|
long |
subtract(long amount)
Subtract amount from value (i.e., set value -= amount)
|
long |
swap(SynchronizedLong other)
Atomically swap values with another SynchronizedLong.
|
java.lang.String |
toString() |
long |
xor(long b)
Set value to value ^ b.
|
execute, getLock
public SynchronizedLong(long initialValue)
public SynchronizedLong(long initialValue, java.lang.Object lock)
public final long get()
public long set(long newValue)
public boolean commit(long assumedValue, long newValue)
public long swap(SynchronizedLong other)
public long increment()
public long decrement()
public long add(long amount)
public long subtract(long amount)
public long multiply(long factor)
public long divide(long factor)
public long negate()
public long complement()
public long and(long b)
public long or(long b)
public long xor(long b)
public int compareTo(long other)
public int compareTo(SynchronizedLong 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