| public class java.util.concurrent SynchronousQueue<E>
|
Java SE 6 |
Synchronous queues are similar to rendezvous channels used in CSP and Ada. They are well suited for handoff designs, in which an object running in one thread must sync up with an object running in another thread in order to hand it some information, event, or task.
This class supports an optional fairness policy for ordering waiting producer and consumer threads. By default, this ordering is not guaranteed. However, a queue constructed with fairness set to true grants threads access in FIFO order.
This class and its iterator implement all of the
optional methods of the Collection and Iterator interfaces.
This class is a member of the Java Collections Framework.
| since | 1.5 |
| E | the type of elements held in this collection |
| Constructors | |||
|---|---|---|---|
| public | SynchronousQueue() Creates a SynchronousQueue with nonfair access policy. | ||
| public | SynchronousQueue(boolean fair) Details
Creates a SynchronousQueue with the specified fairness policy.
| ||
| Methods | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| public void | clear() Does nothing. A SynchronousQueue has no internal capacity. | ||||||||
| public boolean | contains(Object o) Details
Always returns false.
A SynchronousQueue has no internal capacity.
| ||||||||
| public boolean | containsAll(Collection c) Details
Returns false unless the given collection is empty.
A SynchronousQueue has no internal capacity.
| ||||||||
| public int | drainTo(Collection c) Details
| ||||||||
| public int | drainTo(Collection c, int maxElements) Details
| ||||||||
| public Iterator | iterator() Details
Returns an empty iterator in which hasNext always returns
false.
| ||||||||
| public boolean | offer(Object o, long timeout, TimeUnit unit) throws InterruptedException Details
Inserts the specified element into this queue, waiting if necessary
up to the specified wait time for another thread to receive it.
| ||||||||
| public boolean | offer(Object e) Details
Inserts the specified element into this queue, if another thread is
waiting to receive it.
| ||||||||
| public Object | peek() Details
Always returns null.
A SynchronousQueue does not return elements
unless actively waited on.
| ||||||||
| public Object | poll(long timeout, TimeUnit unit) throws InterruptedException Details
Retrieves and removes the head of this queue, waiting
if necessary up to the specified wait time, for another thread
to insert it.
| ||||||||
| public Object | poll() Details
Retrieves and removes the head of this queue, if another thread
is currently making an element available.
| ||||||||
| public void | put(Object o) throws InterruptedException Details
Adds the specified element to this queue, waiting if necessary for
another thread to receive it.
| ||||||||
| public int | remainingCapacity() Details
Always returns zero.
A SynchronousQueue has no internal capacity.
| ||||||||
| public boolean | remove(Object o) Details
Always returns false.
A SynchronousQueue has no internal capacity.
| ||||||||
| public boolean | removeAll(Collection c) Details
Always returns false.
A SynchronousQueue has no internal capacity.
| ||||||||
| public boolean | retainAll(Collection c) Details
Always returns false.
A SynchronousQueue has no internal capacity.
| ||||||||
| public int | size() Details
Always returns zero.
A SynchronousQueue has no internal capacity.
| ||||||||
| public Object | take() throws InterruptedException Details
Retrieves and removes the head of this queue, waiting if necessary
for another thread to insert it.
| ||||||||
| public Object[] | toArray() Details
Returns a zero-length array.
| ||||||||
| public Object[]<T> | toArray(Object[] a) Details
Sets the zeroeth element of the specified array to null
(if the array has non-zero length) and returns it.
| ||||||||
| Properties | |||
|---|---|---|---|
| public boolean | isEmpty() Details
Always returns true.
A SynchronousQueue has no internal capacity.
| ||
| About DocWeb · Bundles · Export · Export All | Top 10 · Statistics · Login |
| About Sun · Contact · Privacy · Terms of Use · Trademarks | Java SE 6 · Copyright © 1994-2009 Sun Microsystems, Inc.All rights reserved. Use is subject to license terms |
![]() |
![]() |
|