Class SynchronizedQueue<E>
- java.lang.Object
-
- org.apache.commons.collections4.collection.SynchronizedCollection<E>
-
- org.apache.commons.collections4.queue.SynchronizedQueue<E>
-
- Type Parameters:
E
- the type of the elements in the collection
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.Queue<E>
public class SynchronizedQueue<E> extends SynchronizedCollection<E> implements java.util.Queue<E>
Decorates anotherQueue
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.
- Since:
- 4.2
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.-
Methods inherited from class org.apache.commons.collections4.collection.SynchronizedCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, removeIf, retainAll, size, synchronizedCollection, toArray, toArray, toString
-
-
-
-
Method Detail
-
synchronizedQueue
public static <E> SynchronizedQueue<E> synchronizedQueue(java.util.Queue<E> queue)
Factory method to create a synchronized queue.- Type Parameters:
E
- the type of the elements in the queue- Parameters:
queue
- the queue to decorate, must not be null- Returns:
- a new synchronized Queue
- Throws:
java.lang.NullPointerException
- if queue is null
-
equals
public boolean equals(java.lang.Object object)
- Specified by:
equals
in interfacejava.util.Collection<E>
- Overrides:
equals
in classSynchronizedCollection<E>
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.util.Collection<E>
- Overrides:
hashCode
in classSynchronizedCollection<E>
-
-