< prev index next >

src/java.base/share/classes/java/util/concurrent/SynchronousQueue.java

Print this page




  63  * {@code poll()} will return {@code null}.  For purposes of other
  64  * {@code Collection} methods (for example {@code contains}), a
  65  * {@code SynchronousQueue} acts as an empty collection.  This queue
  66  * does not permit {@code null} elements.
  67  *
  68  * <p>Synchronous queues are similar to rendezvous channels used in
  69  * CSP and Ada. They are well suited for handoff designs, in which an
  70  * object running in one thread must sync up with an object running
  71  * in another thread in order to hand it some information, event, or
  72  * task.
  73  *
  74  * <p>This class supports an optional fairness policy for ordering
  75  * waiting producer and consumer threads.  By default, this ordering
  76  * is not guaranteed. However, a queue constructed with fairness set
  77  * to {@code true} grants threads access in FIFO order.
  78  *
  79  * <p>This class and its iterator implement all of the <em>optional</em>
  80  * methods of the {@link Collection} and {@link Iterator} interfaces.
  81  *
  82  * <p>This class is a member of the
  83  * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  84  * Java Collections Framework</a>.
  85  *
  86  * @since 1.5
  87  * @author Doug Lea and Bill Scherer and Michael Scott
  88  * @param <E> the type of elements held in this queue
  89  */
  90 public class SynchronousQueue<E> extends AbstractQueue<E>
  91     implements BlockingQueue<E>, java.io.Serializable {
  92     private static final long serialVersionUID = -3223113410248163686L;
  93 
  94     /*
  95      * This class implements extensions of the dual stack and dual
  96      * queue algorithms described in "Nonblocking Concurrent Objects
  97      * with Condition Synchronization", by W. N. Scherer III and
  98      * M. L. Scott.  18th Annual Conf. on Distributed Computing,
  99      * Oct. 2004 (see also
 100      * http://www.cs.rochester.edu/u/scott/synchronization/pseudocode/duals.html).
 101      * The (Lifo) stack is used for non-fair mode, and the (Fifo)
 102      * queue for fair mode. The performance of the two is generally
 103      * similar. Fifo usually supports higher throughput under




  63  * {@code poll()} will return {@code null}.  For purposes of other
  64  * {@code Collection} methods (for example {@code contains}), a
  65  * {@code SynchronousQueue} acts as an empty collection.  This queue
  66  * does not permit {@code null} elements.
  67  *
  68  * <p>Synchronous queues are similar to rendezvous channels used in
  69  * CSP and Ada. They are well suited for handoff designs, in which an
  70  * object running in one thread must sync up with an object running
  71  * in another thread in order to hand it some information, event, or
  72  * task.
  73  *
  74  * <p>This class supports an optional fairness policy for ordering
  75  * waiting producer and consumer threads.  By default, this ordering
  76  * is not guaranteed. However, a queue constructed with fairness set
  77  * to {@code true} grants threads access in FIFO order.
  78  *
  79  * <p>This class and its iterator implement all of the <em>optional</em>
  80  * methods of the {@link Collection} and {@link Iterator} interfaces.
  81  *
  82  * <p>This class is a member of the
  83  * <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
  84  * Java Collections Framework</a>.
  85  *
  86  * @since 1.5
  87  * @author Doug Lea and Bill Scherer and Michael Scott
  88  * @param <E> the type of elements held in this queue
  89  */
  90 public class SynchronousQueue<E> extends AbstractQueue<E>
  91     implements BlockingQueue<E>, java.io.Serializable {
  92     private static final long serialVersionUID = -3223113410248163686L;
  93 
  94     /*
  95      * This class implements extensions of the dual stack and dual
  96      * queue algorithms described in "Nonblocking Concurrent Objects
  97      * with Condition Synchronization", by W. N. Scherer III and
  98      * M. L. Scott.  18th Annual Conf. on Distributed Computing,
  99      * Oct. 2004 (see also
 100      * http://www.cs.rochester.edu/u/scott/synchronization/pseudocode/duals.html).
 101      * The (Lifo) stack is used for non-fair mode, and the (Fifo)
 102      * queue for fair mode. The performance of the two is generally
 103      * similar. Fifo usually supports higher throughput under


< prev index next >