public class ConcurrentLinkedBlockingQueue2<T> extends ConcurrentLinkedQueue<T> implements BlockingQueue<T>
Modifier and Type | Field and Description |
---|---|
protected int |
capacity |
protected AtomicInteger |
count |
protected Condition |
not_empty |
protected Lock |
not_empty_lock |
Constructor and Description |
---|
ConcurrentLinkedBlockingQueue2(int capacity) |
Modifier and Type | Method and Description |
---|---|
protected void |
decrCount() |
int |
drainTo(Collection<? super T> c) |
int |
drainTo(Collection<? super T> c,
int maxElements) |
protected void |
incrCount() |
boolean |
offer(T t)
Drops elements if capacity has been reached.
|
boolean |
offer(T t,
long timeout,
TimeUnit unit) |
T |
poll() |
T |
poll(long timeout,
TimeUnit unit) |
void |
put(T t) |
int |
remainingCapacity() |
boolean |
remove(Object o) |
int |
size() |
T |
take() |
protected void |
waitForNotEmpty() |
add, addAll, contains, isEmpty, iterator, peek, spliterator, toArray, toArray
clear, element, remove
containsAll, removeAll, retainAll, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, contains
addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray
protected final int capacity
protected final AtomicInteger count
protected final Lock not_empty_lock
protected final Condition not_empty
public ConcurrentLinkedBlockingQueue2(int capacity)
public boolean offer(T t)
offer
in interface BlockingQueue<T>
offer
in interface Queue<T>
offer
in class ConcurrentLinkedQueue<T>
t
- public T take() throws InterruptedException
take
in interface BlockingQueue<T>
InterruptedException
public T poll()
public T poll(long timeout, TimeUnit unit) throws InterruptedException
poll
in interface BlockingQueue<T>
InterruptedException
public boolean remove(Object o)
remove
in interface Collection<T>
remove
in interface BlockingQueue<T>
remove
in class ConcurrentLinkedQueue<T>
public int remainingCapacity()
remainingCapacity
in interface BlockingQueue<T>
public int drainTo(Collection<? super T> c)
drainTo
in interface BlockingQueue<T>
public void put(T t) throws InterruptedException
put
in interface BlockingQueue<T>
InterruptedException
public boolean offer(T t, long timeout, TimeUnit unit) throws InterruptedException
offer
in interface BlockingQueue<T>
InterruptedException
public int size()
size
in interface Collection<T>
size
in class ConcurrentLinkedQueue<T>
public int drainTo(Collection<? super T> c, int maxElements)
drainTo
in interface BlockingQueue<T>
protected void waitForNotEmpty() throws InterruptedException
InterruptedException
protected void decrCount()
protected void incrCount()
Copyright © 2023 JBoss, a division of Red Hat. All rights reserved.