< prev index next >

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

Print this page




  36 package java.util.concurrent;
  37 
  38 import java.util.Collection;
  39 import java.util.Queue;
  40 
  41 /**
  42  * A {@link java.util.Queue} that additionally supports operations
  43  * that wait for the queue to become non-empty when retrieving an
  44  * element, and wait for space to become available in the queue when
  45  * storing an element.
  46  *
  47  * <p>{@code BlockingQueue} methods come in four forms, with different ways
  48  * of handling operations that cannot be satisfied immediately, but may be
  49  * satisfied at some point in the future:
  50  * one throws an exception, the second returns a special value (either
  51  * {@code null} or {@code false}, depending on the operation), the third
  52  * blocks the current thread indefinitely until the operation can succeed,
  53  * and the fourth blocks for only a given maximum time limit before giving
  54  * up.  These methods are summarized in the following table:
  55  *
  56  * <table BORDER CELLPADDING=3 CELLSPACING=1>
  57  * <caption>Summary of BlockingQueue methods</caption>
  58  *  <tr>
  59  *    <td></td>
  60  *    <td style="text-align:center"><em>Throws exception</em></td>
  61  *    <td style="text-align:center"><em>Special value</em></td>
  62  *    <td style="text-align:center"><em>Blocks</em></td>
  63  *    <td style="text-align:center"><em>Times out</em></td>
  64  *  </tr>
  65  *  <tr>
  66  *    <td><b>Insert</b></td>
  67  *    <td>{@link #add add(e)}</td>
  68  *    <td>{@link #offer offer(e)}</td>
  69  *    <td>{@link #put put(e)}</td>
  70  *    <td>{@link #offer(Object, long, TimeUnit) offer(e, time, unit)}</td>
  71  *  </tr>
  72  *  <tr>
  73  *    <td><b>Remove</b></td>
  74  *    <td>{@link #remove remove()}</td>
  75  *    <td>{@link #poll poll()}</td>
  76  *    <td>{@link #take take()}</td>




  36 package java.util.concurrent;
  37 
  38 import java.util.Collection;
  39 import java.util.Queue;
  40 
  41 /**
  42  * A {@link java.util.Queue} that additionally supports operations
  43  * that wait for the queue to become non-empty when retrieving an
  44  * element, and wait for space to become available in the queue when
  45  * storing an element.
  46  *
  47  * <p>{@code BlockingQueue} methods come in four forms, with different ways
  48  * of handling operations that cannot be satisfied immediately, but may be
  49  * satisfied at some point in the future:
  50  * one throws an exception, the second returns a special value (either
  51  * {@code null} or {@code false}, depending on the operation), the third
  52  * blocks the current thread indefinitely until the operation can succeed,
  53  * and the fourth blocks for only a given maximum time limit before giving
  54  * up.  These methods are summarized in the following table:
  55  *
  56  * <table class="plain">
  57  * <caption>Summary of BlockingQueue methods</caption>
  58  *  <tr>
  59  *    <td></td>
  60  *    <td style="text-align:center"><em>Throws exception</em></td>
  61  *    <td style="text-align:center"><em>Special value</em></td>
  62  *    <td style="text-align:center"><em>Blocks</em></td>
  63  *    <td style="text-align:center"><em>Times out</em></td>
  64  *  </tr>
  65  *  <tr>
  66  *    <td><b>Insert</b></td>
  67  *    <td>{@link #add add(e)}</td>
  68  *    <td>{@link #offer offer(e)}</td>
  69  *    <td>{@link #put put(e)}</td>
  70  *    <td>{@link #offer(Object, long, TimeUnit) offer(e, time, unit)}</td>
  71  *  </tr>
  72  *  <tr>
  73  *    <td><b>Remove</b></td>
  74  *    <td>{@link #remove remove()}</td>
  75  *    <td>{@link #poll poll()}</td>
  76  *    <td>{@link #take take()}</td>


< prev index next >