BlockingQueue

https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingQueue.html

BlockingQueue methods come in four forms, with different ways of handling operations that cannot be satisfied immediately, but may be satisfied at some point in the future:

  1. one throws an exception,
  2. the second returns a special value (either null or false, depending on the operation),
  3. the third blocks the current thread indefinitely until the operation can succeed,
  4. and the fourth blocks for only a given maximum time limit before giving up. These methods are summarized in the following table:
Throws exception Special value Blocks Times out
Insert add(e) offer(e) put(e) [offer(e, time, unit)](https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingQueue.html#offer(E, long, java.util.concurrent.TimeUnit))
Remove remove() [poll()](https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingQueue.html#poll(long, java.util.concurrent.TimeUnit)) take() [poll(time, unit)](https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingQueue.html#poll(long, java.util.concurrent.TimeUnit))
Examine element() peek() not applicable not applicable