Apache Tomcat 7.0.4

org.apache.tomcat.util.threads
Class TaskQueue

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
          extended by java.util.concurrent.LinkedBlockingQueue<Runnable>
              extended by org.apache.tomcat.util.threads.TaskQueue
All Implemented Interfaces:
Serializable, Iterable<Runnable>, Collection<Runnable>, BlockingQueue<Runnable>, Queue<Runnable>

public class TaskQueue
extends LinkedBlockingQueue<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 wont be able to force items unto the queue itself

Author:
fhanik
See Also:
Serialized Form

Constructor Summary
TaskQueue()
           
TaskQueue(Collection<? extends Runnable> c)
           
TaskQueue(int capacity)
           
 
Method Summary
 boolean force(Runnable o)
           
 boolean force(Runnable o, long timeout, TimeUnit unit)
           
 boolean offer(Runnable o)
           
 void setParent(ThreadPoolExecutor tp)
           
 
Methods inherited from class java.util.concurrent.LinkedBlockingQueue
clear, drainTo, drainTo, iterator, offer, peek, poll, poll, put, remainingCapacity, remove, size, take, toArray, toArray, toString
 
Methods inherited from class java.util.AbstractQueue
add, addAll, element, remove
 
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, removeAll, retainAll
 
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, contains
 
Methods inherited from interface java.util.Queue
element, remove
 
Methods inherited from interface java.util.Collection
addAll, containsAll, equals, hashCode, isEmpty, removeAll, retainAll
 

Constructor Detail

TaskQueue

public TaskQueue()

TaskQueue

public TaskQueue(int capacity)

TaskQueue

public TaskQueue(Collection<? extends Runnable> c)
Method Detail

setParent

public void setParent(ThreadPoolExecutor tp)

force

public boolean force(Runnable o)

force

public boolean force(Runnable o,
                     long timeout,
                     TimeUnit unit)
              throws InterruptedException
Throws:
InterruptedException

offer

public boolean offer(Runnable o)
Specified by:
offer in interface BlockingQueue<Runnable>
Specified by:
offer in interface Queue<Runnable>
Overrides:
offer in class LinkedBlockingQueue<Runnable>

Apache Tomcat 7.0.4

Copyright © 2000-2010 Apache Software Foundation. All Rights Reserved.