E - the type of the elements in the collectionpublic class SynchronizedQueue<E> extends SynchronizedCollection<E> implements java.util.Queue<E>
Queue to synchronize its behaviour for a multi-threaded environment.
Methods are synchronized, then forwarded to the decorated queue. Iterators must be separately synchronized around the loop.
| Modifier and Type | Field and Description |
|---|---|
private static long |
serialVersionUID
Serialization version
|
lock| Modifier | Constructor and Description |
|---|---|
protected |
SynchronizedQueue(java.util.Queue<E> queue)
Constructor that wraps (not copies).
|
protected |
SynchronizedQueue(java.util.Queue<E> queue,
java.lang.Object lock)
Constructor that wraps (not copies).
|
| Modifier and Type | Method and Description |
|---|---|
protected java.util.Queue<E> |
decorated()
Gets the queue being decorated.
|
E |
element() |
boolean |
equals(java.lang.Object object) |
int |
hashCode() |
boolean |
offer(E e) |
E |
peek() |
E |
poll() |
E |
remove() |
static <E> SynchronizedQueue<E> |
synchronizedQueue(java.util.Queue<E> queue)
Factory method to create a synchronized queue.
|
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, removeIf, retainAll, size, synchronizedCollection, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitprivate static final long serialVersionUID
protected SynchronizedQueue(java.util.Queue<E> queue)
queue - the queue to decorate, must not be nulljava.lang.NullPointerException - if queue is nullprotected SynchronizedQueue(java.util.Queue<E> queue, java.lang.Object lock)
queue - the queue to decorate, must not be nulllock - the lock to use, must not be nulljava.lang.NullPointerException - if queue or lock is nullpublic static <E> SynchronizedQueue<E> synchronizedQueue(java.util.Queue<E> queue)
E - the type of the elements in the queuequeue - the queue to decorate, must not be nulljava.lang.NullPointerException - if queue is nullprotected java.util.Queue<E> decorated()
decorated in class SynchronizedCollection<E>public boolean equals(java.lang.Object object)
equals in interface java.util.Collection<E>equals in class SynchronizedCollection<E>public int hashCode()
hashCode in interface java.util.Collection<E>hashCode in class SynchronizedCollection<E>