Package org.apache.tomcat.util.threads
Class TaskQueue
- All Implemented Interfaces:
Serializable
,Iterable<Runnable>
,Collection<Runnable>
,BlockingQueue<Runnable>
,Queue<Runnable>
As task queue specifically designed to run with a thread pool executor. The
task queue is optimised to properly utilize threads within a thread pool
executor. If you use a normal queue, the executor will spawn threads when
there are idle threads and you won't be able to force items onto the queue
itself.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Methods inherited from class java.util.concurrent.LinkedBlockingQueue
clear, contains, drainTo, drainTo, forEach, iterator, offer, peek, poll, put, remainingCapacity, remove, removeAll, removeIf, retainAll, size, spliterator, toArray, toArray, toString
Methods inherited from class java.util.AbstractQueue
add, addAll, element, remove
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.concurrent.BlockingQueue
add
Methods inherited from interface java.util.Collection
addAll, containsAll, equals, hashCode, isEmpty, parallelStream, stream, toArray
-
Field Details
-
sm
-
-
Constructor Details
-
TaskQueue
public TaskQueue() -
TaskQueue
public TaskQueue(int capacity) -
TaskQueue
-
-
Method Details
-
setParent
-
force
Used to add a task to the queue if the task has been rejected by the Executor.- Parameters:
o
- The task to add to the queue- Returns:
true
if the task was added to the queue, otherwisefalse
-
offer
- Specified by:
offer
in interfaceBlockingQueue<Runnable>
- Specified by:
offer
in interfaceQueue<Runnable>
- Overrides:
offer
in classLinkedBlockingQueue<Runnable>
-
poll
- Specified by:
poll
in interfaceBlockingQueue<Runnable>
- Overrides:
poll
in classLinkedBlockingQueue<Runnable>
- Throws:
InterruptedException
-
take
- Specified by:
take
in interfaceBlockingQueue<Runnable>
- Overrides:
take
in classLinkedBlockingQueue<Runnable>
- Throws:
InterruptedException
-