E
- the type of the elements in the collectionpublic class SynchronizedQueue<E> extends SynchronizedCollection<E> implements 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.
lock
Modifier | Constructor and Description |
---|---|
protected |
SynchronizedQueue(Queue<E> queue)
Constructor that wraps (not copies).
|
protected |
SynchronizedQueue(Queue<E> queue,
Object lock)
Constructor that wraps (not copies).
|
Modifier and Type | Method and Description |
---|---|
protected Queue<E> |
decorated()
Gets the queue being decorated.
|
E |
element() |
boolean |
equals(Object object) |
int |
hashCode() |
boolean |
offer(E e) |
E |
peek() |
E |
poll() |
E |
remove() |
static <E> SynchronizedQueue<E> |
synchronizedQueue(Queue<E> queue)
Factory method to create a synchronized queue.
|
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, synchronizedCollection, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, clear, contains, containsAll, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray
protected SynchronizedQueue(Queue<E> queue)
queue
- the queue to decorate, must not be nullNullPointerException
- if queue is nullprotected SynchronizedQueue(Queue<E> queue, Object lock)
queue
- the queue to decorate, must not be nulllock
- the lock to use, must not be nullNullPointerException
- if queue or lock is nullpublic static <E> SynchronizedQueue<E> synchronizedQueue(Queue<E> queue)
E
- the type of the elements in the queuequeue
- the queue to decorate, must not be nullNullPointerException
- if queue is nullprotected Queue<E> decorated()
decorated
in class SynchronizedCollection<E>
public boolean equals(Object object)
equals
in interface Collection<E>
equals
in class SynchronizedCollection<E>
public int hashCode()
hashCode
in interface Collection<E>
hashCode
in class SynchronizedCollection<E>
Copyright © 2001–2018 The Apache Software Foundation. All rights reserved.