E - the type of elements held in this collectionpublic class ArrayBlockingQueueWithShutdown<E>
extends java.util.AbstractQueue<E>
implements java.util.concurrent.BlockingQueue<E>
shutdown() and start() methods. Will
throw InterruptedException if Queue has been shutdown on take() and
poll(long, TimeUnit).
Based on ArrayBlockingQueue of OpenJDK by Doug Lea (who released ArrayBlockingQueue as public domain).
| Constructor and Description |
|---|
ArrayBlockingQueueWithShutdown(int capacity) |
ArrayBlockingQueueWithShutdown(int capacity,
boolean fair) |
| Modifier and Type | Method and Description |
|---|---|
int |
drainTo(java.util.Collection<? super E> c) |
int |
drainTo(java.util.Collection<? super E> c,
int maxElements) |
boolean |
isShutdown()
Returns true if the queue is currently shut down.
|
java.util.Iterator<E> |
iterator() |
boolean |
offer(E e) |
boolean |
offer(E e,
long timeout,
java.util.concurrent.TimeUnit unit) |
E |
peek() |
E |
poll() |
E |
poll(long timeout,
java.util.concurrent.TimeUnit unit) |
void |
put(E e) |
int |
remainingCapacity() |
void |
shutdown()
Shutdown the Queue.
|
int |
size() |
void |
start()
Start the queue.
|
E |
take() |
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitpublic ArrayBlockingQueueWithShutdown(int capacity)
public ArrayBlockingQueueWithShutdown(int capacity,
boolean fair)
public void shutdown()
public void start()
shutdown().public boolean isShutdown()
public boolean offer(E e)
public void put(E e) throws java.lang.InterruptedException
put in interface java.util.concurrent.BlockingQueue<E>java.lang.InterruptedExceptionpublic boolean offer(E e, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
offer in interface java.util.concurrent.BlockingQueue<E>java.lang.InterruptedExceptionpublic E take() throws java.lang.InterruptedException
take in interface java.util.concurrent.BlockingQueue<E>java.lang.InterruptedExceptionpublic E poll(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
poll in interface java.util.concurrent.BlockingQueue<E>java.lang.InterruptedExceptionpublic int remainingCapacity()
remainingCapacity in interface java.util.concurrent.BlockingQueue<E>public int drainTo(java.util.Collection<? super E> c)
drainTo in interface java.util.concurrent.BlockingQueue<E>public int drainTo(java.util.Collection<? super E> c, int maxElements)
drainTo in interface java.util.concurrent.BlockingQueue<E>public int size()