Class WaitableChar
java.lang.Object
EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable
EDU.oswego.cs.dl.util.concurrent.SynchronizedChar
EDU.oswego.cs.dl.util.concurrent.WaitableChar
- All Implemented Interfaces:
Executor, Cloneable, Comparable
A class useful for offloading waiting and signalling operations
on single char variables.
-
Field Summary
Fields inherited from class SynchronizedChar
value_Fields inherited from class SynchronizedVariable
lock_ -
Constructor Summary
ConstructorsConstructorDescriptionWaitableChar(char initialValue) Make a new WaitableChar with the given initial value, and using its own internal lock.WaitableChar(char initialValue, Object lock) Make a new WaitableChar with the given initial value, and using the supplied lock. -
Method Summary
Modifier and TypeMethodDescriptioncharadd(char amount) Add amount to value (i.e., set value += amount)booleancommit(char assumedValue, char newValue) Set value to newValue only if it is currently assumedValue.chardivide(char factor) Divide value by factor (i.e., set value /= factor)charmultiply(char factor) Multiply value by factor (i.e., set value *= factor)charset(char newValue) Set to newValue.charsubtract(char amount) Subtract amount from value (i.e., set value -= amount)voidWait until value equals c, then run action if nonnull.voidwhenGreater(char c, Runnable action) wait until value greater than c, then run action if nonnull.voidwhenGreaterEqual(char c, Runnable action) wait until value greater than or equal to c, then run action if nonnull.voidwait until value less than c, then run action if nonnull.voidwhenLessEqual(char c, Runnable action) wait until value less than or equal to c, then run action if nonnull.voidwhenNotEqual(char c, Runnable action) wait until value not equal to c, then run action if nonnull.Methods inherited from class SynchronizedChar
compareTo, compareTo, compareTo, equals, get, hashCode, swap, toStringMethods inherited from class SynchronizedVariable
execute, getLock
-
Constructor Details
-
WaitableChar
public WaitableChar(char initialValue) Make a new WaitableChar with the given initial value, and using its own internal lock. -
WaitableChar
Make a new WaitableChar with the given initial value, and using the supplied lock.
-
-
Method Details
-
set
public char set(char newValue) Description copied from class:SynchronizedCharSet to newValue.- Overrides:
setin classSynchronizedChar- Returns:
- the old value
-
commit
public boolean commit(char assumedValue, char newValue) Description copied from class:SynchronizedCharSet value to newValue only if it is currently assumedValue.- Overrides:
commitin classSynchronizedChar- Returns:
- true if successful
-
add
public char add(char amount) Description copied from class:SynchronizedCharAdd amount to value (i.e., set value += amount)- Overrides:
addin classSynchronizedChar- Returns:
- the new value
-
subtract
public char subtract(char amount) Description copied from class:SynchronizedCharSubtract amount from value (i.e., set value -= amount)- Overrides:
subtractin classSynchronizedChar- Returns:
- the new value
-
multiply
public char multiply(char factor) Description copied from class:SynchronizedCharMultiply value by factor (i.e., set value *= factor)- Overrides:
multiplyin classSynchronizedChar- Returns:
- the new value
-
divide
public char divide(char factor) Description copied from class:SynchronizedCharDivide value by factor (i.e., set value /= factor)- Overrides:
dividein classSynchronizedChar- Returns:
- the new value
-
whenEqual
Wait until value equals c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenNotEqual
wait until value not equal to c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenLessEqual
wait until value less than or equal to c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenLess
wait until value less than c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenGreaterEqual
wait until value greater than or equal to c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenGreater
wait until value greater than c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-