public class WaitableInt extends SynchronizedInt
value_lock_| Constructor and Description |
|---|
WaitableInt(int initialValue)
Make a new WaitableInt with the given initial value,
and using its own internal lock.
|
WaitableInt(int initialValue,
java.lang.Object lock)
Make a new WaitableInt 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 |
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)
|
int |
increment()
Increment the value.
|
int |
multiply(int factor)
Multiply value by factor (i.e., set value *= factor)
|
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)
|
void |
whenEqual(int c,
java.lang.Runnable action)
Wait until value equals c, then run action if nonnull.
|
void |
whenGreater(int c,
java.lang.Runnable action)
wait until value greater than c, then run action if nonnull.
|
void |
whenGreaterEqual(int c,
java.lang.Runnable action)
wait until value greater than or equal to c, then run action if nonnull.
|
void |
whenLess(int c,
java.lang.Runnable action)
wait until value less than c, then run action if nonnull.
|
void |
whenLessEqual(int c,
java.lang.Runnable action)
wait until value less than or equal to c, then run action if nonnull.
|
void |
whenNotEqual(int c,
java.lang.Runnable action)
wait until value not equal to c, then run action if nonnull.
|
int |
xor(int b)
Set value to value ^ b.
|
compareTo, compareTo, compareTo, equals, get, hashCode, negate, swap, toStringexecute, getLockpublic WaitableInt(int initialValue)
public WaitableInt(int initialValue,
java.lang.Object lock)
public int set(int newValue)
SynchronizedIntset in class SynchronizedIntpublic boolean commit(int assumedValue,
int newValue)
SynchronizedIntcommit in class SynchronizedIntpublic int increment()
SynchronizedIntincrement in class SynchronizedIntpublic int decrement()
SynchronizedIntdecrement in class SynchronizedIntpublic int add(int amount)
SynchronizedIntadd in class SynchronizedIntpublic int subtract(int amount)
SynchronizedIntsubtract in class SynchronizedIntpublic int multiply(int factor)
SynchronizedIntmultiply in class SynchronizedIntpublic int divide(int factor)
SynchronizedIntdivide in class SynchronizedIntpublic int complement()
complement in class SynchronizedIntpublic int and(int b)
and in class SynchronizedIntpublic int or(int b)
or in class SynchronizedIntpublic int xor(int b)
xor in class SynchronizedIntpublic void whenEqual(int c,
java.lang.Runnable action)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic void whenNotEqual(int c,
java.lang.Runnable action)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic void whenLessEqual(int c,
java.lang.Runnable action)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic void whenLess(int c,
java.lang.Runnable action)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic void whenGreaterEqual(int c,
java.lang.Runnable action)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic void whenGreater(int c,
java.lang.Runnable action)
throws java.lang.InterruptedException
java.lang.InterruptedException