net.sf.beanlib.util.concurrent
Class ConcurrentLinkedBlockingQueue<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
net.sf.beanlib.util.concurrent.ConcurrentLinkedBlockingQueue<E>
- Type Parameters:
E
- the type of elements held in this collection
- All Implemented Interfaces:
- Serializable, Iterable<E>, Collection<E>, BlockingQueue<E>, Queue<E>
- Direct Known Subclasses:
- ConcurrentLinkedBoundedBlockingQueue
public class ConcurrentLinkedBlockingQueue<E>
- extends AbstractQueue<E>
- implements Serializable, BlockingQueue<E>
An unbounded concurrent blocking queue implemented upon
ConcurrentLinkedQueue
.
Note there is currently no such class in Java 6.
In contrast to LinkedBlockingQueue
which is always bounded, a ConcurrentLinkedBlockingQueue is unbounded.
- Author:
- Hanson Char
- See Also:
- Serialized Form
Methods inherited from interface java.util.Collection |
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
parkq
private final ConcurrentLinkedQueue<ConcurrentLinkedBlockingQueue.ThreadMarker> parkq
q
private final ConcurrentLinkedQueue<E> q
ConcurrentLinkedBlockingQueue
public ConcurrentLinkedBlockingQueue()
ConcurrentLinkedBlockingQueue
public ConcurrentLinkedBlockingQueue(Collection<? extends E> c)
iterator
public Iterator<E> iterator()
- Specified by:
iterator
in interface Iterable<E>
- Specified by:
iterator
in interface Collection<E>
- Specified by:
iterator
in class AbstractCollection<E>
size
public int size()
- Specified by:
size
in interface Collection<E>
- Specified by:
size
in class AbstractCollection<E>
offer
public boolean offer(E e)
- Specified by:
offer
in interface BlockingQueue<E>
- Specified by:
offer
in interface Queue<E>
peek
public E peek()
- Specified by:
peek
in interface Queue<E>
poll
public E poll()
- Specified by:
poll
in interface Queue<E>
take
public E take()
throws InterruptedException
- Retrieves and removes the head of this queue, waiting if necessary until
an element becomes available.
- Specified by:
take
in interface BlockingQueue<E>
- Returns:
- the head of this queue
- Throws:
InterruptedException
- if interrupted while waiting
poll
public E poll(long timeout,
TimeUnit unit)
throws InterruptedException
- Retrieves and removes the head of this queue, waiting up to the specified
wait time if necessary for an element to become available.
- Specified by:
poll
in interface BlockingQueue<E>
- Parameters:
timeout
- how long to wait before giving up, in units of unit.
A negative timeout is treated the same as to wait forever.unit
- a TimeUnit determining how to interpret the
timeout parameter
- Returns:
- the head of this queue, or null if the specified
waiting time elapses before an element is available
- Throws:
InterruptedException
- if interrupted while waiting
put
public void put(E e)
throws InterruptedException
- Specified by:
put
in interface BlockingQueue<E>
- Throws:
InterruptedException
offer
public boolean offer(E e,
long timeout,
TimeUnit unit)
throws InterruptedException
- Specified by:
offer
in interface BlockingQueue<E>
- Throws:
InterruptedException
remainingCapacity
public int remainingCapacity()
- Specified by:
remainingCapacity
in interface BlockingQueue<E>
drainTo
public int drainTo(Collection<? super E> c)
- Specified by:
drainTo
in interface BlockingQueue<E>
drainTo
public int drainTo(Collection<? super E> c,
int maxElements)
- Specified by:
drainTo
in interface BlockingQueue<E>