EDU.oswego.cs.dl.util.concurrent

Class WaitableShort

public class WaitableShort extends SynchronizedShort

A class useful for offloading waiting and signalling operations on single short variables.

[ Introduction to this package. ]

Constructor Summary
WaitableShort(short initialValue)
Make a new WaitableShort with the given initial value, and using its own internal lock.
WaitableShort(short initialValue, Object lock)
Make a new WaitableShort with the given initial value, and using the supplied lock.
Method Summary
shortadd(short amount)
shortand(short b)
Set value to value & b.
booleancommit(short assumedValue, short newValue)
shortcomplement()
Set the value to its complement
shortdecrement()
shortdivide(short factor)
shortincrement()
shortmultiply(short factor)
shortor(short b)
Set value to value | b.
shortset(short newValue)
shortsubtract(short amount)
voidwhenEqual(short c, Runnable action)
Wait until value equals c, then run action if nonnull.
voidwhenGreater(short c, Runnable action)
wait until value greater than c, then run action if nonnull.
voidwhenGreaterEqual(short c, Runnable action)
wait until value greater than or equal to c, then run action if nonnull.
voidwhenLess(short c, Runnable action)
wait until value less than c, then run action if nonnull.
voidwhenLessEqual(short c, Runnable action)
wait until value less than or equal to c, then run action if nonnull.
voidwhenNotEqual(short c, Runnable action)
wait until value not equal to c, then run action if nonnull.
shortxor(short b)
Set value to value ^ b.

Constructor Detail

WaitableShort

public WaitableShort(short initialValue)
Make a new WaitableShort with the given initial value, and using its own internal lock.

WaitableShort

public WaitableShort(short initialValue, Object lock)
Make a new WaitableShort with the given initial value, and using the supplied lock.

Method Detail

add

public short add(short amount)

and

public short and(short b)
Set value to value & b.

Returns: the new value

commit

public boolean commit(short assumedValue, short newValue)

complement

public short complement()
Set the value to its complement

Returns: the new value

decrement

public short decrement()

divide

public short divide(short factor)

increment

public short increment()

multiply

public short multiply(short factor)

or

public short or(short b)
Set value to value | b.

Returns: the new value

set

public short set(short newValue)

subtract

public short subtract(short amount)

whenEqual

public void whenEqual(short c, Runnable action)
Wait until value equals c, then run action if nonnull. The action is run with the synchronization lock held.

whenGreater

public void whenGreater(short c, Runnable action)
wait until value greater than c, then run action if nonnull. The action is run with the synchronization lock held.

whenGreaterEqual

public void whenGreaterEqual(short c, Runnable action)
wait until value greater than or equal to c, then run action if nonnull. The action is run with the synchronization lock held.

whenLess

public void whenLess(short c, Runnable action)
wait until value less than c, then run action if nonnull. The action is run with the synchronization lock held.

whenLessEqual

public void whenLessEqual(short c, Runnable action)
wait until value less than or equal to c, then run action if nonnull. The action is run with the synchronization lock held.

whenNotEqual

public void whenNotEqual(short c, Runnable action)
wait until value not equal to c, then run action if nonnull. The action is run with the synchronization lock held.

xor

public short xor(short b)
Set value to value ^ b.

Returns: the new value