Java in a Nutshell, 5th Edition [Electronic resources]

نسخه متنی -صفحه : 1191/ 800
نمايش فراداده

SynchronousQueue<E>java.util.concurrent

Java 5.0serializable collection

This BlockingQueue implementation is the degenerate case of a bounded queue with a capacity of zero. Every call to put( ) blocks until a corresponding call to take( ), and vice versa. You can think of this as an Exchanger that does only a one-way exchange.

The size( ) and remainingCapacity( ) methods always return 0. The peek( ) method always returns null. The iterator( ) method returns an Iterator for which the hasNext( ) method returns false.

Figure 16-93. java.util.concurrent.SynchronousQueue<E>

public class

SynchronousQueue<E> extends java.util.AbstractQueue<E> implements BlockingQueue<E>, Serializable { // Public Constructors public

SynchronousQueue ( ); public

SynchronousQueue (boolean

fair ); // Methods Implementing BlockingQueue public int

drainTo (java.util.Collection<? super E>

c ); public int

drainTo (java.util.Collection<? super E>

c , int

maxElements ); public boolean

offer (E

o ); public boolean

offer (E

o , long

timeout , TimeUnit

unit ) throws InterruptedException; public E

poll (long

timeout , TimeUnit

unit ) throws InterruptedException; public void

put (E

o ) throws InterruptedException; public int

remainingCapacity ( ); constant public E

take ( ) throws InterruptedException; // Methods Implementing Collection public void

clear ( ); empty public boolean

contains (Object

o ); constant public boolean

containsAll (java.util.Collection<?>

c ); public boolean

isEmpty ( ); constant default:true public java.util.Iterator<E>

iterator ( ); public boolean

remove (Object

o ); constant public boolean

removeAll (java.util.Collection<?>

c ); constant public boolean

retainAll (java.util.Collection<?>

c ); constant public int

size ( ); constant public Object[ ]

toArray ( ); public <T> T[ ]

toArray (T[ ]

a ); // Methods Implementing Queue public E

peek ( ); constant public E

poll ( ); }