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>

public class SynchronizedQueue<E> extends SynchronizedCollection<E> implements Queue<E>
Decorates another 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.

Since:
4.2
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization version
      See Also:
  • Constructor Details

    • SynchronizedQueue

      protected SynchronizedQueue(Queue<E> queue)
      Constructor that wraps (not copies).
      Parameters:
      queue - the queue to decorate, must not be null
      Throws:
      NullPointerException - if queue is null
    • SynchronizedQueue

      protected SynchronizedQueue(Queue<E> queue, Object lock)
      Constructor 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