< prev index next >

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

Print this page




  59  * operations obtain elements at the head of the queue.
  60  *
  61  * <p>This is a classic &quot;bounded buffer&quot;, in which a
  62  * fixed-sized array holds elements inserted by producers and
  63  * extracted by consumers.  Once created, the capacity cannot be
  64  * changed.  Attempts to {@code put} an element into a full queue
  65  * will result in the operation blocking; attempts to {@code take} an
  66  * element from an empty queue will similarly block.
  67  *
  68  * <p>This class supports an optional fairness policy for ordering
  69  * waiting producer and consumer threads.  By default, this ordering
  70  * is not guaranteed. However, a queue constructed with fairness set
  71  * to {@code true} grants threads access in FIFO order. Fairness
  72  * generally decreases throughput but reduces variability and avoids
  73  * starvation.
  74  *
  75  * <p>This class and its iterator implement all of the <em>optional</em>
  76  * methods of the {@link Collection} and {@link Iterator} interfaces.
  77  *
  78  * <p>This class is a member of the
  79  * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
  80  * Java Collections Framework</a>.
  81  *
  82  * @since 1.5
  83  * @author Doug Lea
  84  * @param <E> the type of elements held in this queue
  85  */
  86 public class ArrayBlockingQueue<E> extends AbstractQueue<E>
  87         implements BlockingQueue<E>, java.io.Serializable {
  88 
  89     /*
  90      * Much of the implementation mechanics, especially the unusual
  91      * nested loops, are shared and co-maintained with ArrayDeque.
  92      */
  93 
  94     /**
  95      * Serialization ID. This class relies on default serialization
  96      * even for the items array, which is default-serialized, even if
  97      * it is empty. Otherwise it could not be declared final, which is
  98      * necessary here.
  99      */




  59  * operations obtain elements at the head of the queue.
  60  *
  61  * <p>This is a classic &quot;bounded buffer&quot;, in which a
  62  * fixed-sized array holds elements inserted by producers and
  63  * extracted by consumers.  Once created, the capacity cannot be
  64  * changed.  Attempts to {@code put} an element into a full queue
  65  * will result in the operation blocking; attempts to {@code take} an
  66  * element from an empty queue will similarly block.
  67  *
  68  * <p>This class supports an optional fairness policy for ordering
  69  * waiting producer and consumer threads.  By default, this ordering
  70  * is not guaranteed. However, a queue constructed with fairness set
  71  * to {@code true} grants threads access in FIFO order. Fairness
  72  * generally decreases throughput but reduces variability and avoids
  73  * starvation.
  74  *
  75  * <p>This class and its iterator implement all of the <em>optional</em>
  76  * methods of the {@link Collection} and {@link Iterator} interfaces.
  77  *
  78  * <p>This class is a member of the
  79  * <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
  80  * Java Collections Framework</a>.
  81  *
  82  * @since 1.5
  83  * @author Doug Lea
  84  * @param <E> the type of elements held in this queue
  85  */
  86 public class ArrayBlockingQueue<E> extends AbstractQueue<E>
  87         implements BlockingQueue<E>, java.io.Serializable {
  88 
  89     /*
  90      * Much of the implementation mechanics, especially the unusual
  91      * nested loops, are shared and co-maintained with ArrayDeque.
  92      */
  93 
  94     /**
  95      * Serialization ID. This class relies on default serialization
  96      * even for the items array, which is default-serialized, even if
  97      * it is empty. Otherwise it could not be declared final, which is
  98      * necessary here.
  99      */


< prev index next >