java.util.concurrent
Class SynchronousQueue<E>

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.util.AbstractCollection sample code for java.util.AbstractCollection definition code for java.util.AbstractCollection <E>
      extended by java.util.AbstractQueue sample code for java.util.AbstractQueue definition code for java.util.AbstractQueue <E>
          extended by java.util.concurrent.SynchronousQueue<E>
Type Parameters:
E - the type of elements held in this collection
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Iterable sample code for java.lang.Iterable definition code for java.lang.Iterable <E>, Collection sample code for java.util.Collection definition code for java.util.Collection <E>, BlockingQueue sample code for java.util.concurrent.BlockingQueue definition code for java.util.concurrent.BlockingQueue <E>, Queue sample code for java.util.Queue definition code for java.util.Queue <E>

public class SynchronousQueue<E>
extends AbstractQueue sample code for java.util.AbstractQueue definition code for java.util.AbstractQueue <E>
implements BlockingQueue sample code for java.util.concurrent.BlockingQueue definition code for java.util.concurrent.BlockingQueue <E>, Serializable sample code for java.io.Serializable definition code for java.io.Serializable

A blocking queue sample code for java.util.concurrent.BlockingQueue definition code for java.util.concurrent.BlockingQueue in which each put must wait for a take, and vice versa. A synchronous queue does not have any internal capacity, not even a capacity of one. You cannot peek at a synchronous queue because an element is only present when you try to take it; you cannot add an element (using any method) unless another thread is trying to remove it; you cannot iterate as there is nothing to iterate. The head of the queue is the element that the first queued thread is trying to add to the queue; if there are no queued threads then no element is being added and the head is null. For purposes of other Collection methods (for example contains), a SynchronousQueue acts as an empty collection. This queue does not permit null elements.

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. Fairness generally decreases throughput but reduces variability and avoids starvation.

This class and its iterator implement all of the optional methods of the Collection sample code for java.util.Collection definition code for java.util.Collection and Iterator sample code for java.util.Iterator definition code for java.util.Iterator interfaces.

This class is a member of the Java Collections Framework.

Since:
1.5
See Also:
Serialized Form

Constructor Summary
SynchronousQueue sample code for java.util.concurrent.SynchronousQueue.SynchronousQueue() definition code for java.util.concurrent.SynchronousQueue.SynchronousQueue() ()
          Creates a SynchronousQueue with nonfair access policy.
SynchronousQueue sample code for java.util.concurrent.SynchronousQueue.SynchronousQueue(boolean) definition code for java.util.concurrent.SynchronousQueue.SynchronousQueue(boolean) (boolean fair)
          Creates a SynchronousQueue with specified fairness policy.
 
Method Summary
 void clear sample code for java.util.concurrent.SynchronousQueue.clear() definition code for java.util.concurrent.SynchronousQueue.clear() ()
          Does nothing.
 boolean contains sample code for java.util.concurrent.SynchronousQueue.contains(java.lang.Object) definition code for java.util.concurrent.SynchronousQueue.contains(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  o)
          Always returns false.
 boolean containsAll sample code for java.util.concurrent.SynchronousQueue.containsAll(java.util.Collection) definition code for java.util.concurrent.SynchronousQueue.containsAll(java.util.Collection) (Collection sample code for java.util.Collection definition code for java.util.Collection <?> c)
          Returns false unless given collection is empty.
 int drainTo sample code for java.util.concurrent.SynchronousQueue.drainTo(java.util.Collection) definition code for java.util.concurrent.SynchronousQueue.drainTo(java.util.Collection) (Collection sample code for java.util.Collection definition code for java.util.Collection <? super E> c)
          Removes all available elements from this queue and adds them into the given collection.
 int drainTo sample code for java.util.concurrent.SynchronousQueue.drainTo(java.util.Collection, int) definition code for java.util.concurrent.SynchronousQueue.drainTo(java.util.Collection, int) (Collection sample code for java.util.Collection definition code for java.util.Collection <? super E> c, int maxElements)
          Removes at most the given number of available elements from this queue and adds them into the given collection.
 boolean isEmpty sample code for java.util.concurrent.SynchronousQueue.isEmpty() definition code for java.util.concurrent.SynchronousQueue.isEmpty() ()
          Always returns true.
 Iterator sample code for java.util.Iterator definition code for java.util.Iterator <E> iterator sample code for java.util.concurrent.SynchronousQueue.iterator() definition code for java.util.concurrent.SynchronousQueue.iterator() ()
          Returns an empty iterator in which hasNext always returns false.
 boolean offer sample code for java.util.concurrent.SynchronousQueue.offer(E) definition code for java.util.concurrent.SynchronousQueue.offer(E) (E o)
          Inserts the specified element into this queue, if another thread is waiting to receive it.
 boolean offer sample code for java.util.concurrent.SynchronousQueue.offer(E, long, java.util.concurrent.TimeUnit) definition code for java.util.concurrent.SynchronousQueue.offer(E, long, java.util.concurrent.TimeUnit) (E o, long timeout, TimeUnit sample code for java.util.concurrent.TimeUnit definition code for java.util.concurrent.TimeUnit  unit)
          Inserts the specified element into this queue, waiting if necessary up to the specified wait time for another thread to receive it.
 E peek sample code for java.util.concurrent.SynchronousQueue.peek() definition code for java.util.concurrent.SynchronousQueue.peek() ()
          Always returns null.
 E poll sample code for java.util.concurrent.SynchronousQueue.poll() definition code for java.util.concurrent.SynchronousQueue.poll() ()
          Retrieves and removes the head of this queue, if another thread is currently making an element available.
 E poll sample code for java.util.concurrent.SynchronousQueue.poll(long, java.util.concurrent.TimeUnit) definition code for java.util.concurrent.SynchronousQueue.poll(long, java.util.concurrent.TimeUnit) (long timeout, TimeUnit sample code for java.util.concurrent.TimeUnit definition code for java.util.concurrent.TimeUnit  unit)
          Retrieves and removes the head of this queue, waiting if necessary up to the specified wait time, for another thread to insert it.
 void put sample code for java.util.concurrent.SynchronousQueue.put(E) definition code for java.util.concurrent.SynchronousQueue.put(E) (E o)
          Adds the specified element to this queue, waiting if necessary for another thread to receive it.
 int remainingCapacity sample code for java.util.concurrent.SynchronousQueue.remainingCapacity() definition code for java.util.concurrent.SynchronousQueue.remainingCapacity() ()
          Always returns zero.
 boolean remove sample code for java.util.concurrent.SynchronousQueue.remove(java.lang.Object) definition code for java.util.concurrent.SynchronousQueue.remove(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  o)
          Always returns false.
 boolean removeAll sample code for java.util.concurrent.SynchronousQueue.removeAll(java.util.Collection) definition code for java.util.concurrent.SynchronousQueue.removeAll(java.util.Collection) (Collection sample code for java.util.Collection definition code for java.util.Collection <?> c)
          Always returns false.
 boolean retainAll sample code for java.util.concurrent.SynchronousQueue.retainAll(java.util.Collection) definition code for java.util.concurrent.SynchronousQueue.retainAll(java.util.Collection) (Collection sample code for java.util.Collection definition code for java.util.Collection <?> c)
          Always returns false.
 int size sample code for java.util.concurrent.SynchronousQueue.size() definition code for java.util.concurrent.SynchronousQueue.size() ()
          Always returns zero.
 E take sample code for java.util.concurrent.SynchronousQueue.take() definition code for java.util.concurrent.SynchronousQueue.take() ()
          Retrieves and removes the head of this queue, waiting if necessary for another thread to insert it.
 Object sample code for java.lang.Object definition code for java.lang.Object [] toArray sample code for java.util.concurrent.SynchronousQueue.toArray() definition code for java.util.concurrent.SynchronousQueue.toArray() ()
          Returns a zero-length array.
<T> T[]
toArray sample code for java.util.concurrent.SynchronousQueue.toArray(T[]) definition code for java.util.concurrent.SynchronousQueue.toArray(T[]) (T[] a)
          Sets the zeroeth element of the specified array to null (if the array has non-zero length) and returns it.
 
Methods inherited from class java.util.AbstractQueue sample code for java.util.AbstractQueue definition code for java.util.AbstractQueue
add sample code for java.util.AbstractQueue.add(E) definition code for java.util.AbstractQueue.add(E) , addAll sample code for java.util.AbstractQueue.addAll(java.util.Collection) definition code for java.util.AbstractQueue.addAll(java.util.Collection) , element sample code for java.util.AbstractQueue.element() definition code for java.util.AbstractQueue.element() , remove sample code for java.util.AbstractQueue.remove() definition code for java.util.AbstractQueue.remove()
 
Methods inherited from class java.util.AbstractCollection sample code for java.util.AbstractCollection definition code for java.util.AbstractCollection
toString sample code for java.util.AbstractCollection.toString() definition code for java.util.AbstractCollection.toString()
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 
Methods inherited from interface java.util.concurrent.BlockingQueue sample code for java.util.concurrent.BlockingQueue definition code for java.util.concurrent.BlockingQueue
add sample code for java.util.concurrent.BlockingQueue.add(E) definition code for java.util.concurrent.BlockingQueue.add(E)
 
Methods inherited from interface java.util.Queue sample code for java.util.Queue definition code for java.util.Queue
element sample code for java.util.Queue.element() definition code for java.util.Queue.element() , remove sample code for java.util.Queue.remove() definition code for java.util.Queue.remove()
 
Methods inherited from interface java.util.Collection sample code for java.util.Collection definition code for java.util.Collection
addAll sample code for java.util.Collection.addAll(java.util.Collection) definition code for java.util.Collection.addAll(java.util.Collection) , equals sample code for java.util.Collection.equals(java.lang.Object) definition code for java.util.Collection.equals(java.lang.Object) , hashCode sample code for java.util.Collection.hashCode() definition code for java.util.Collection.hashCode()
 

Constructor Detail

SynchronousQueue sample code for java.util.concurrent.SynchronousQueue() definition code for java.util.concurrent.SynchronousQueue()

public SynchronousQueue()
Creates a SynchronousQueue with nonfair access policy.


SynchronousQueue sample code for java.util.concurrent.SynchronousQueue(boolean) definition code for java.util.concurrent.SynchronousQueue(boolean)

public SynchronousQueue(boolean fair)
Creates a SynchronousQueue with specified fairness policy.

Parameters:
fair - if true, threads contend in FIFO order for access; otherwise the order is unspecified.
Method Detail

put sample code for java.util.concurrent.SynchronousQueue.put(E) definition code for java.util.concurrent.SynchronousQueue.put(E)

public void put(E o)
         throws InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException 
Adds the specified element to this queue, waiting if necessary for another thread to receive it.

Specified by:
put sample code for java.util.concurrent.BlockingQueue.put(E) definition code for java.util.concurrent.BlockingQueue.put(E) in interface BlockingQueue sample code for java.util.concurrent.BlockingQueue definition code for java.util.concurrent.BlockingQueue <E>
Parameters:
o - the element to add
Throws:
InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException - if interrupted while waiting.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if the specified element is null.

offer sample code for java.util.concurrent.SynchronousQueue.offer(E, long, java.util.concurrent.TimeUnit) definition code for java.util.concurrent.SynchronousQueue.offer(E, long, java.util.concurrent.TimeUnit)

public boolean offer(E o,
                     long timeout,
                     TimeUnit sample code for java.util.concurrent.TimeUnit definition code for java.util.concurrent.TimeUnit  unit)
              throws InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException 
Inserts the specified element into this queue, waiting if necessary up to the specified wait time for another thread to receive it.

Specified by:
offer sample code for java.util.concurrent.BlockingQueue.offer(E, long, java.util.concurrent.TimeUnit) definition code for java.util.concurrent.BlockingQueue.offer(E, long, java.util.concurrent.TimeUnit) in interface BlockingQueue sample code for java.util.concurrent.BlockingQueue definition code for java.util.concurrent.BlockingQueue <E>
Parameters:
o - the element to add
timeout - how long to wait before giving up, in units of unit
unit - a TimeUnit determining how to interpret the timeout parameter
Returns:
true if successful, or false if the specified waiting time elapses before a consumer appears.
Throws:
InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException - if interrupted while waiting.
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if the specified element is null.

take sample code for java.util.concurrent.SynchronousQueue.take() definition code for java.util.concurrent.SynchronousQueue.take()

public E take()
       throws InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException 
Retrieves and removes the head of this queue, waiting if necessary for another thread to insert it.

Specified by:
take sample code for java.util.concurrent.BlockingQueue.take() definition code for java.util.concurrent.BlockingQueue.take() in interface BlockingQueue sample code for java.util.concurrent.BlockingQueue definition code for java.util.concurrent.BlockingQueue <E>
Returns:
the head of this queue
Throws:
InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException - if interrupted while waiting.

poll sample code for java.util.concurrent.SynchronousQueue.poll(long, java.util.concurrent.TimeUnit) definition code for java.util.concurrent.SynchronousQueue.poll(long, java.util.concurrent.TimeUnit)

public E poll(long timeout,
              TimeUnit sample code for java.util.concurrent.TimeUnit definition code for java.util.concurrent.TimeUnit  unit)
       throws InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException 
Retrieves and removes the head of this queue, waiting if necessary up to the specified wait time, for another thread to insert it.

Specified by:
poll sample code for java.util.concurrent.BlockingQueue.poll(long, java.util.concurrent.TimeUnit) definition code for java.util.concurrent.BlockingQueue.poll(long, java.util.concurrent.TimeUnit) in interface BlockingQueue sample code for java.util.concurrent.BlockingQueue definition code for java.util.concurrent.BlockingQueue <E>
Parameters:
timeout - how long to wait before giving up, in units of unit
unit - a TimeUnit determining how to interpret the timeout parameter
Returns:
the head of this queue, or null if the specified waiting time elapses before an element is present.
Throws:
InterruptedException sample code for java.lang.InterruptedException definition code for java.lang.InterruptedException - if interrupted while waiting.

offer sample code for java.util.concurrent.SynchronousQueue.offer(E) definition code for java.util.concurrent.SynchronousQueue.offer(E)

public boolean offer(E o)
Inserts the specified element into this queue, if another thread is waiting to receive it.

Specified by:
offer sample code for java.util.concurrent.BlockingQueue.offer(E) definition code for java.util.concurrent.BlockingQueue.offer(E) in interface BlockingQueue sample code for java.util.concurrent.BlockingQueue definition code for java.util.concurrent.BlockingQueue <E>
Specified by:
offer sample code for java.util.Queue.offer(E) definition code for java.util.Queue.offer(E) in interface Queue sample code for java.util.Queue definition code for java.util.Queue <E>
Parameters:
o - the element to add.
Returns:
true if it was possible to add the element to this queue, else false
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if the specified element is null

poll sample code for java.util.concurrent.SynchronousQueue.poll() definition code for java.util.concurrent.SynchronousQueue.poll()

public E poll()
Retrieves and removes the head of this queue, if another thread is currently making an element available.

Specified by:
poll sample code for java.util.Queue.poll() definition code for java.util.Queue.poll() in interface Queue sample code for java.util.Queue definition code for java.util.Queue <E>
Returns:
the head of this queue, or null if no element is available.

isEmpty sample code for java.util.concurrent.SynchronousQueue.isEmpty() definition code for java.util.concurrent.SynchronousQueue.isEmpty()

public boolean isEmpty()
Always returns true. A SynchronousQueue has no internal capacity.

Specified by:
isEmpty sample code for java.util.Collection.isEmpty() definition code for java.util.Collection.isEmpty() in interface Collection sample code for java.util.Collection definition code for java.util.Collection <E>
Overrides:
isEmpty sample code for java.util.AbstractCollection.isEmpty() definition code for java.util.AbstractCollection.isEmpty() in class AbstractCollection sample code for java.util.AbstractCollection definition code for java.util.AbstractCollection <E>
Returns:
true

size sample code for java.util.concurrent.SynchronousQueue.size() definition code for java.util.concurrent.SynchronousQueue.size()

public int size()
Always returns zero. A SynchronousQueue has no internal capacity.

Specified by:
size sample code for java.util.Collection.size() definition code for java.util.Collection.size() in interface Collection sample code for java.util.Collection definition code for java.util.Collection <E>
Specified by:
size sample code for java.util.AbstractCollection.size() definition code for java.util.AbstractCollection.size() in class AbstractCollection sample code for java.util.AbstractCollection definition code for java.util.AbstractCollection <E>
Returns:
zero.

remainingCapacity sample code for java.util.concurrent.SynchronousQueue.remainingCapacity() definition code for java.util.concurrent.SynchronousQueue.remainingCapacity()

public int remainingCapacity()
Always returns zero. A SynchronousQueue has no internal capacity.

Specified by:
remainingCapacity sample code for java.util.concurrent.BlockingQueue.remainingCapacity() definition code for java.util.concurrent.BlockingQueue.remainingCapacity() in interface BlockingQueue sample code for java.util.concurrent.BlockingQueue definition code for java.util.concurrent.BlockingQueue <E>
Returns:
zero.

clear sample code for java.util.concurrent.SynchronousQueue.clear() definition code for java.util.concurrent.SynchronousQueue.clear()

public void clear()
Does nothing. A SynchronousQueue has no internal capacity.

Specified by:
clear sample code for java.util.Collection.clear() definition code for java.util.Collection.clear() in interface Collection sample code for java.util.Collection definition code for java.util.Collection <E>
Overrides:
clear sample code for java.util.AbstractQueue.clear() definition code for java.util.AbstractQueue.clear() in class AbstractQueue sample code for java.util.AbstractQueue definition code for java.util.AbstractQueue <E>

contains sample code for java.util.concurrent.SynchronousQueue.contains(java.lang.Object) definition code for java.util.concurrent.SynchronousQueue.contains(java.lang.Object)

public boolean contains(Object sample code for java.lang.Object definition code for java.lang.Object  o)
Always returns false. A SynchronousQueue has no internal capacity.

Specified by:
contains sample code for java.util.Collection.contains(java.lang.Object) definition code for java.util.Collection.contains(java.lang.Object) in interface Collection sample code for java.util.Collection definition code for java.util.Collection <E>
Overrides:
contains sample code for java.util.AbstractCollection.contains(java.lang.Object) definition code for java.util.AbstractCollection.contains(java.lang.Object) in class AbstractCollection sample code for java.util.AbstractCollection definition code for java.util.AbstractCollection <E>
Parameters:
o - the element
Returns:
false

remove sample code for java.util.concurrent.SynchronousQueue.remove(java.lang.Object) definition code for java.util.concurrent.SynchronousQueue.remove(java.lang.Object)

public boolean remove(Object sample code for java.lang.Object definition code for java.lang.Object  o)
Always returns false. A SynchronousQueue has no internal capacity.

Specified by:
remove sample code for java.util.Collection.remove(java.lang.Object) definition code for java.util.Collection.remove(java.lang.Object) in interface Collection sample code for java.util.Collection definition code for java.util.Collection <E>
Overrides:
remove sample code for java.util.AbstractCollection.remove(java.lang.Object) definition code for java.util.AbstractCollection.remove(java.lang.Object) in class AbstractCollection sample code for java.util.AbstractCollection definition code for java.util.AbstractCollection <E>
Parameters:
o - the element to remove
Returns:
false

containsAll sample code for java.util.concurrent.SynchronousQueue.containsAll(java.util.Collection<?>) definition code for java.util.concurrent.SynchronousQueue.containsAll(java.util.Collection<?>)

public boolean containsAll(Collection sample code for java.util.Collection definition code for java.util.Collection <?> c)
Returns false unless given collection is empty. A SynchronousQueue has no internal capacity.

Specified by:
containsAll sample code for java.util.Collection.containsAll(java.util.Collection) definition code for java.util.Collection.containsAll(java.util.Collection) in interface Collection sample code for java.util.Collection definition code for java.util.Collection <E>
Overrides:
containsAll sample code for java.util.AbstractCollection.containsAll(java.util.Collection) definition code for java.util.AbstractCollection.containsAll(java.util.Collection) in class AbstractCollection sample code for java.util.AbstractCollection definition code for java.util.AbstractCollection <E>
Parameters:
c - the collection
Returns:
false unless given collection is empty
See Also:
AbstractCollection.contains(Object) sample code for java.util.AbstractCollection.contains(java.lang.Object) definition code for java.util.AbstractCollection.contains(java.lang.Object)

removeAll sample code for java.util.concurrent.SynchronousQueue.removeAll(java.util.Collection<?>) definition code for java.util.concurrent.SynchronousQueue.removeAll(java.util.Collection<?>)

public boolean removeAll(Collection sample code for java.util.Collection definition code for java.util.Collection <?> c)
Always returns false. A SynchronousQueue has no internal capacity.

Specified by:
removeAll sample code for java.util.Collection.removeAll(java.util.Collection) definition code for java.util.Collection.removeAll(java.util.Collection) in interface Collection sample code for java.util.Collection definition code for java.util.Collection <E>
Overrides:
removeAll sample code for java.util.AbstractCollection.removeAll(java.util.Collection) definition code for java.util.AbstractCollection.removeAll(java.util.Collection) in class AbstractCollection sample code for java.util.AbstractCollection definition code for java.util.AbstractCollection <E>
Parameters:
c - the collection
Returns:
false
See Also:
AbstractCollection.remove(Object) sample code for java.util.AbstractCollection.remove(java.lang.Object) definition code for java.util.AbstractCollection.remove(java.lang.Object) , AbstractCollection.contains(Object) sample code for java.util.AbstractCollection.contains(java.lang.Object) definition code for java.util.AbstractCollection.contains(java.lang.Object)

retainAll sample code for java.util.concurrent.SynchronousQueue.retainAll(java.util.Collection<?>) definition code for java.util.concurrent.SynchronousQueue.retainAll(java.util.Collection<?>)

public boolean retainAll(Collection sample code for java.util.Collection definition code for java.util.Collection <?> c)
Always returns false. A SynchronousQueue has no internal capacity.

Specified by:
retainAll sample code for java.util.Collection.retainAll(java.util.Collection) definition code for java.util.Collection.retainAll(java.util.Collection) in interface Collection sample code for java.util.Collection definition code for java.util.Collection <E>
Overrides:
retainAll sample code for java.util.AbstractCollection.retainAll(java.util.Collection) definition code for java.util.AbstractCollection.retainAll(java.util.Collection) in class AbstractCollection sample code for java.util.AbstractCollection definition code for java.util.AbstractCollection <E>
Parameters:
c - the collection
Returns:
false
See Also:
AbstractCollection.remove(Object) sample code for java.util.AbstractCollection.remove(java.lang.Object) definition code for java.util.AbstractCollection.remove(java.lang.Object) , AbstractCollection.contains(Object) sample code for java.util.AbstractCollection.contains(java.lang.Object) definition code for java.util.AbstractCollection.contains(java.lang.Object)

peek sample code for java.util.concurrent.SynchronousQueue.peek() definition code for java.util.concurrent.SynchronousQueue.peek()

public E peek()
Always returns null. A SynchronousQueue does not return elements unless actively waited on.

Specified by:
peek sample code for java.util.Queue.peek() definition code for java.util.Queue.peek() in interface Queue sample code for java.util.Queue definition code for java.util.Queue <E>
Returns:
null

iterator sample code for java.util.concurrent.SynchronousQueue.iterator() definition code for java.util.concurrent.SynchronousQueue.iterator()

public Iterator sample code for java.util.Iterator definition code for java.util.Iterator <E> iterator()
Returns an empty iterator in which hasNext always returns false.

Specified by:
iterator sample code for java.lang.Iterable.iterator() definition code for java.lang.Iterable.iterator() in interface Iterable sample code for java.lang.Iterable definition code for java.lang.Iterable <E>
Specified by:
iterator sample code for java.util.Collection.iterator() definition code for java.util.Collection.iterator() in interface Collection sample code for java.util.Collection definition code for java.util.Collection <E>
Specified by:
iterator sample code for java.util.AbstractCollection.iterator() definition code for java.util.AbstractCollection.iterator() in class AbstractCollection sample code for java.util.AbstractCollection definition code for java.util.AbstractCollection <E>
Returns:
an empty iterator

toArray sample code for java.util.concurrent.SynchronousQueue.toArray() definition code for java.util.concurrent.SynchronousQueue.toArray()

public Object sample code for java.lang.Object definition code for java.lang.Object [] toArray()
Returns a zero-length array.

Specified by:
toArray sample code for java.util.Collection.toArray() definition code for java.util.Collection.toArray() in interface Collection sample code for java.util.Collection definition code for java.util.Collection <E>
Overrides:
toArray sample code for java.util.AbstractCollection.toArray() definition code for java.util.AbstractCollection.toArray() in class AbstractCollection sample code for java.util.AbstractCollection definition code for java.util.AbstractCollection <E>
Returns:
a zero-length array

toArray sample code for java.util.concurrent.SynchronousQueue.<T>toArray(T[]) definition code for java.util.concurrent.SynchronousQueue.<T>toArray(T[])

public <T> T[] toArray(T[] a)
Sets the zeroeth element of the specified array to null (if the array has non-zero length) and returns it.

Specified by:
toArray sample code for java.util.Collection.toArray(T[]) definition code for java.util.Collection.toArray(T[]) in interface Collection sample code for java.util.Collection definition code for java.util.Collection <E>
Overrides:
toArray sample code for java.util.AbstractCollection.toArray(T[]) definition code for java.util.AbstractCollection.toArray(T[]) in class AbstractCollection sample code for java.util.AbstractCollection definition code for java.util.AbstractCollection <E>
Parameters:
a - the array
Returns:
the specified array

drainTo sample code for java.util.concurrent.SynchronousQueue.drainTo(java.util.Collection<? super E>) definition code for java.util.concurrent.SynchronousQueue.drainTo(java.util.Collection<? super E>)

public int drainTo(Collection sample code for java.util.Collection definition code for java.util.Collection <? super E> c)
Description copied from interface: BlockingQueue sample code for java.util.concurrent.BlockingQueue.drainTo(java.util.Collection) definition code for java.util.concurrent.BlockingQueue.drainTo(java.util.Collection)
Removes all available elements from this queue and adds them into the given collection. This operation may be more efficient than repeatedly polling this queue. A failure encountered while attempting to add elements to collection c may result in elements being in neither, either or both collections when the associated exception is thrown. Attempts to drain a queue to itself result in IllegalArgumentException. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

Specified by:
drainTo sample code for java.util.concurrent.BlockingQueue.drainTo(java.util.Collection) definition code for java.util.concurrent.BlockingQueue.drainTo(java.util.Collection) in interface BlockingQueue sample code for java.util.concurrent.BlockingQueue definition code for java.util.concurrent.BlockingQueue <E>
Parameters:
c - the collection to transfer elements into
Returns:
the number of elements transferred.

drainTo sample code for java.util.concurrent.SynchronousQueue.drainTo(java.util.Collection<? super E>, int) definition code for java.util.concurrent.SynchronousQueue.drainTo(java.util.Collection<? super E>, int)

public int drainTo(Collection sample code for java.util.Collection definition code for java.util.Collection <? super E> c,
                   int maxElements)
Description copied from interface: BlockingQueue sample code for java.util.concurrent.BlockingQueue.drainTo(java.util.Collection, int) definition code for java.util.concurrent.BlockingQueue.drainTo(java.util.Collection, int)
Removes at most the given number of available elements from this queue and adds them into the given collection. A failure encountered while attempting to add elements to collection c may result in elements being in neither, either or both collections when the associated exception is thrown. Attempts to drain a queue to itself result in IllegalArgumentException. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

Specified by:
drainTo sample code for java.util.concurrent.BlockingQueue.drainTo(java.util.Collection, int) definition code for java.util.concurrent.BlockingQueue.drainTo(java.util.Collection, int) in interface BlockingQueue sample code for java.util.concurrent.BlockingQueue definition code for java.util.concurrent.BlockingQueue <E>
Parameters:
c - the collection to transfer elements into
maxElements - the maximum number of elements to transfer
Returns:
the number of elements transferred.