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:
- Serializable,- Iterable<E>,- Collection<E>,- Queue<E>
Decorates another 
Queue to synchronize its behavior for a multithreaded environment.
 Methods are synchronized, then forwarded to the decorated queue. Iterators must be separately synchronized around the loop.
- Since:
- 4.2
- See Also:
- 
Field SummaryFields inherited from class org.apache.commons.collections4.collection.SynchronizedCollectionlock
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedSynchronizedQueue(Queue<E> queue) Constructor that wraps (not copies).protectedSynchronizedQueue(Queue<E> queue, Object lock) Constructor that wraps (not copies).
- 
Method SummaryModifier and TypeMethodDescriptionGets the queue being decorated.element()booleaninthashCode()booleanpeek()poll()remove()static <E> SynchronizedQueue<E> synchronizedQueue(Queue<E> queue) Factory method to create a synchronized queue.Methods inherited from class org.apache.commons.collections4.collection.SynchronizedCollectionadd, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, removeIf, retainAll, size, synchronizedCollection, toArray, toArray, toStringMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.CollectionaddAll, clear, contains, containsAll, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray
- 
Constructor Details- 
SynchronizedQueueConstructor that wraps (not copies).- Parameters:
- queue- the queue to decorate, must not be null
- Throws:
- NullPointerException- if queue is null
 
- 
SynchronizedQueueConstructor that wraps (not copies).- Parameters:
- queue- the queue to decorate, must not be null
- lock- the lock to use, must not be null
- Throws:
- NullPointerException- if queue or lock is null
 
 
- 
- 
Method Details- 
synchronizedQueueFactory 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:
- NullPointerException- if queue is null
 
- 
decorated
- 
element
- 
equals- Specified by:
- equalsin interface- Collection<E>
- Overrides:
- equalsin class- SynchronizedCollection<E>
 
- 
hashCode- Specified by:
- hashCodein interface- Collection<E>
- Overrides:
- hashCodein class- SynchronizedCollection<E>
 
- 
offer
- 
peek
- 
poll
- 
remove
 
-