public class SynchronizedInt extends SynchronizedVariable implements Comparable, Cloneable
Modifier and Type | Field and Description |
---|---|
protected int |
value_ |
lock_
Constructor and Description |
---|
SynchronizedInt(int initialValue)
Make a new SynchronizedInt with the given initial value,
and using its own internal lock.
|
SynchronizedInt(int initialValue,
Object lock)
Make a new SynchronizedInt with the given initial value,
and using the supplied lock.
|
Modifier and Type | Method and Description |
---|---|
int |
add(int amount)
Add amount to value (i.e., set value += amount)
|
int |
and(int b)
Set value to value & b.
|
boolean |
commit(int assumedValue,
int newValue)
Set value to newValue only if it is currently assumedValue.
|
int |
compareTo(int other) |
int |
compareTo(Object other) |
int |
compareTo(SynchronizedInt other) |
int |
complement()
Set the value to its complement
|
int |
decrement()
Decrement the value.
|
int |
divide(int factor)
Divide value by factor (i.e., set value /= factor)
|
boolean |
equals(Object other) |
int |
get()
Return the current value
|
int |
hashCode() |
int |
increment()
Increment the value.
|
int |
multiply(int factor)
Multiply value by factor (i.e., set value *= factor)
|
int |
negate()
Set the value to the negative of its old value
|
int |
or(int b)
Set value to value | b.
|
int |
set(int newValue)
Set to newValue.
|
int |
subtract(int amount)
Subtract amount from value (i.e., set value -= amount)
|
int |
swap(SynchronizedInt other)
Atomically swap values with another SynchronizedInt.
|
String |
toString() |
int |
xor(int b)
Set value to value ^ b.
|
execute, getLock
public SynchronizedInt(int initialValue)
public SynchronizedInt(int initialValue, Object lock)
public final int get()
public int set(int newValue)
public boolean commit(int assumedValue, int newValue)
public int swap(SynchronizedInt other)
public int increment()
public int decrement()
public int add(int amount)
public int subtract(int amount)
public int multiply(int factor)
public int divide(int factor)
public int negate()
public int complement()
public int and(int b)
public int or(int b)
public int xor(int b)
public int compareTo(int other)
public int compareTo(SynchronizedInt other)
public int compareTo(Object other)
compareTo
in interface Comparable
Copyright © 2002–2024. All rights reserved.