If you only need threads to synch up without exchanging information, consider using a Barrier. If you need bidirectional exchanges, consider using a Rendezvous.
Introduction to this package., CyclicBarrier, Rendezvous
| Modifier and Type | Class and Description |
|---|---|
| protected static class | SynchronousChannel.Queue
Simple FIFO queue class to hold waiting puts/takes. |
| Modifier and Type | Field and Description |
|---|---|
| protected static final Object | CANCELLED
Special marker used in queue nodes to indicate that the thread waiting for a change in the node has timed out or been interrupted. |
| protected final SynchronousChannel. | |
| protected final SynchronousChannel. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: zero -- Synchronous channels have no internal capacity.Implements EDU. |
| public boolean | offer(Object
the element to be inserted. Should be non-null. x, long the number of milliseconds to wait. If less than
or equal to zero, the method does not perform any timed waits,
but might still require
access to a synchronization lock, which can impose unbounded
delay if there is a lot of contention for the channel. msecs)Implements EDU. |
| public Object | Returns: null -- Synchronous channels do not hold contents unless actively takenImplements EDU. |
| public Object | poll(long
the number of milliseconds to wait. If less than
or equal to zero, the operation does not perform any timed waits,
but might still require
access to a synchronization lock, which can impose unbounded
delay if there is a lot of contention for the channel. msecs)Implements EDU. |
| public void | put(Object
the element to be inserted. Should be non-null. x)Implements EDU. |
| public Object | take()
Implements EDU. |
| CANCELLED | back to summary |
|---|---|
| protected static final Object CANCELLED Special marker used in queue nodes to indicate that the thread waiting for a change in the node has timed out or been interrupted. | |
| waitingPuts | back to summary |
|---|---|
| protected final SynchronousChannel. | |
| waitingTakes | back to summary |
|---|---|
| protected final SynchronousChannel. | |
| SynchronousChannel | back to summary |
|---|---|
| public SynchronousChannel() | |
| capacity | back to summary |
|---|---|
| public int capacity() Implements EDU. Doc from EDU. Return the maximum number of elements that can be held.
| |
| offer | back to summary |
|---|---|
| public boolean offer(Object x, long msecs) throws InterruptedException Implements EDU. Doc from EDU. Place item in channel only if it can be accepted within msecs milliseconds. The time bound is interpreted in a coarse-grained, best-effort fashion.
| |
| peek | back to summary |
|---|---|
| public Object peek() Implements EDU. Doc from EDU. Return, but do not remove object at head of Channel, or null if it is empty.
| |
| poll | back to summary |
|---|---|
| public Object poll(long msecs) throws InterruptedException Implements EDU. Doc from EDU. Return and remove an item from channel only if one is available within msecs milliseconds. The time bound is interpreted in a coarse grained, best-effort fashion.
| |
| put | back to summary |
|---|---|
| public void put(Object x) throws InterruptedException Implements EDU. Doc from EDU. Place item in the channel, possibly waiting indefinitely until it can be accepted. Channels implementing the BoundedChannel subinterface are generally guaranteed to block on puts upon reaching capacity, but other implementations may or may not block.
| |
| take | back to summary |
|---|---|
| public Object take() throws InterruptedException Implements EDU. Doc from EDU. Return and remove an item from channel, possibly waiting indefinitely until such an item exists.
| |
| Modifier and Type | Field and Description |
|---|---|
| protected LinkedNode | |
| protected LinkedNode |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected LinkedNode | |
| protected void |
| head | back to summary |
|---|---|
| protected LinkedNode head | |
| last | back to summary |
|---|---|
| protected LinkedNode last | |
| Queue | back to summary |
|---|---|
| protected Queue() | |
| deq | back to summary |
|---|---|
| protected LinkedNode deq() | |
| enq | back to summary |
|---|---|
| protected void enq(LinkedNode p) | |