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 final long | serialVersionUID
Hides org. |
| Access | Constructor and Description |
|---|---|
| protected | SynchronizedQueue(final Queue<E>
the queue to decorate, must not be null queue)Constructor that wraps (not copies). |
| protected | SynchronizedQueue(final Queue<E>
the queue to decorate, must not be null queue, final Object the lock to use, must not be null lock)Constructor that wraps (not copies). |
| Modifier and Type | Method and Description |
|---|---|
| protected Queue | Returns: the decorated queueOverrides org. |
| public E | element()
Implements java. |
| public boolean | equals(final Object
object to be compared for equality with this collection object)Overrides org. Implements java. |
| public int | hashCode()
Overrides org. Implements java. |
| public boolean | offer(final E
the element to add e)Implements java. |
| public E | peek()
Implements java. null if this queue is empty.
|
| public E | poll()
Implements java. null if this queue is empty.
|
| public E | |
| public static < the type of the elements in the queue E> SynchronizedQueue | Returns: a new synchronized Queuethe queue to decorate, must not be null queue)Factory method to create a synchronized queue. |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serialization version | |
| SynchronizedQueue | back to summary |
|---|---|
| protected SynchronizedQueue(final Queue<E> queue) Constructor that wraps (not copies).
| |
| SynchronizedQueue | back to summary |
|---|---|
| protected SynchronizedQueue(final Queue<E> queue, final Object lock) Constructor that wraps (not copies).
| |
| decorated | back to summary |
|---|---|
| protected Queue Overrides org. Gets the queue being decorated. | |
| element | back to summary |
|---|---|
| public E element() Implements java. Doc from java. Retrieves, but does not remove, the head of this queue. This method
differs from
| |
| equals | back to summary |
|---|---|
| public boolean equals(final Object object) Overrides org. Implements java. Doc from java. Compares the specified object with this collection for equality.
While the
The general contract for the | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides org. Implements java. Doc from java. Returns the hash code value for this collection. While the
| |
| offer | back to summary |
|---|---|
| public boolean offer(final E e) Implements java. Doc from java. Inserts the specified element into this queue if it is possible to do
so immediately without violating capacity restrictions.
When using a capacity-restricted queue, this method is generally
preferable to
| |
| peek | back to summary |
|---|---|
| public E peek() Implements java. Doc from java. Retrieves, but does not remove, the head of this queue,
or returns
| |
| poll | back to summary |
|---|---|
| public E poll() Implements java. Doc from java. Retrieves and removes the head of this queue,
or returns
| |
| remove | back to summary |
|---|---|
| public E remove() Implements java. Doc from java. Retrieves and removes the head of this queue. This method differs
from
| |
| synchronizedQueue | back to summary |
|---|---|
| public static <E> SynchronizedQueue Factory method to create a synchronized queue.
| |