Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable
EDU.oswego.cs.dl.util.concurrent.SynchronizedInt
EDU.oswego.cs.dl.util.concurrent.WaitableInt
public class WaitableInt
extends SynchronizedInt
Field Summary |
Fields inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedInt | |
value_ |
Fields inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable | |
lock_ |
Constructor Summary | |
| |
|
Method Summary | |
int |
|
boolean |
|
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedInt | |
add , and , commit , compareTo , compareTo , compareTo , complement , decrement , divide , equals , get , hashCode , increment , multiply , negate , or , set , subtract , swap , toString , xor |
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable | |
execute , getLock |
public WaitableInt(int initialValue)
Make a new WaitableInt with the given initial value, and using its own internal lock.
public WaitableInt(int initialValue, Object lock)
Make a new WaitableInt with the given initial value, and using the supplied lock.
public int add(int amount)
Add amount to value (i.e., set value += amount)
- Overrides:
- add in interface SynchronizedInt
- Returns:
- the new value
public boolean commit(int assumedValue, int newValue)
Set value to newValue only if it is currently assumedValue.
- Overrides:
- commit in interface SynchronizedInt
- Returns:
- true if successful
public int decrement()
Decrement the value.
- Overrides:
- decrement in interface SynchronizedInt
- Returns:
- the new value
public int divide(int factor)
Divide value by factor (i.e., set value /= factor)
- Overrides:
- divide in interface SynchronizedInt
- Returns:
- the new value
public int increment()
Increment the value.
- Overrides:
- increment in interface SynchronizedInt
- Returns:
- the new value
public int multiply(int factor)
Multiply value by factor (i.e., set value *= factor)
- Overrides:
- multiply in interface SynchronizedInt
- Returns:
- the new value
public int set(int newValue)
Set to newValue.
- Overrides:
- set in interface SynchronizedInt
- Returns:
- the old value
public int subtract(int amount)
Subtract amount from value (i.e., set value -= amount)
- Overrides:
- subtract in interface SynchronizedInt
- Returns:
- the new value
public void whenEqual(int c, Runnable action) throws InterruptedException
Wait until value equals c, then run action if nonnull. The action is run with the synchronization lock held.
public void whenGreater(int c, Runnable action) throws InterruptedException
wait until value greater than c, then run action if nonnull. The action is run with the synchronization lock held.
public void whenGreaterEqual(int c, Runnable action) throws InterruptedException
wait until value greater than or equal to c, then run action if nonnull. The action is run with the synchronization lock held.
public void whenLess(int c, Runnable action) throws InterruptedException
wait until value less than c, then run action if nonnull. The action is run with the synchronization lock held.
public void whenLessEqual(int c, Runnable action) throws InterruptedException
wait until value less than or equal to c, then run action if nonnull. The action is run with the synchronization lock held.
public void whenNotEqual(int c, Runnable action) throws InterruptedException
wait until value not equal to c, then run action if nonnull. The action is run with the synchronization lock held.