| 
foundry-0.9.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
  |
  +--java.lang.ThreadGroup
        |
        +--foundry.threads.ThreadPool
A ThreadGroup that pools ThreadPool.PooledThreads.  Substantial
 portions of this class include software developed by GO.com
 (http://opensource.go.com/); those portions are governed by the
 Tea Software
 License, Version 1.0.
| Inner Class Summary | |
private  class | 
ThreadPool.PooledThread
 | 
| Field Summary | |
private  int | 
active
The number of active ThreadPool.PooledThreads in this
  ThreadPool. | 
private  long | 
idleTimeout
The number of milliseconds that ThreadPool.PooledThreads in this
  ThreadPool should wait before aging off. | 
private  boolean | 
isClosed
A flag indicating whether this ThreadPool is closed. | 
private  boolean | 
isDaemon
A flag indicating whether new ThreadPool.PooledThreads in this
  ThreadPool should be created as daemon ThreadPool.PooledThreads. | 
private  Collection | 
listeners
A Collection of ThreadPoolListeners that are
  alerted when ThreadPool.PooledThreads become available and leave this
  ThreadPool. | 
private  int | 
max
The maximum number of ThreadPool.PooledThreads allowed. | 
private  LinkedList | 
pool
The pool itself; a LinkedList of ThreadPool.PooledThreads that
  are idling and ready to perform a job. | 
private  int | 
priority
The priority to be given to new ThreadPool.PooledThreads in this
  ThreadPool. | 
private static int | 
threadID
The number that will be used in new ThreadPool.PooledThread names. | 
private  long | 
timeout
The number of milliseconds to wait for getting ThreadPool.PooledThreads
  out of this ThreadPool. | 
| Fields inherited from class java.lang.ThreadGroup | 
daemon, destroyed, groups, maxPriority, name, ngroups, nthreads, parent, threads, vmAllowSuspension | 
| Constructor Summary | |
ThreadPool(String name,
           int max)
Creates a ThreadPool of daemon ThreadPool.PooledThreads. | 
|
ThreadPool(String name,
           int max,
           boolean isDaemon)
Creates a ThreadPool. | 
|
ThreadPool(ThreadGroup parent,
           String name,
           int max)
Creates a ThreadPool of daemon ThreadPool.PooledThreads. | 
|
ThreadPool(ThreadGroup parent,
           String name,
           int max,
           boolean isDaemon)
Creates a ThreadPool. | 
|
| Method Summary | |
 void | 
addThreadPoolListener(ThreadPoolListener listener)
 | 
 void | 
close()
Closes down all the ThreadPool.PooledThreads in this
 ThreadPool as they become available. | 
 void | 
close(long timeout)
Closes down all the ThreadPool.PooledThreads in this
 ThreadPool as they become available. | 
private  void | 
ensureOpen()
 | 
 Thread[] | 
getAllThreads()
 | 
 int | 
getAvailableCount()
 | 
 long | 
getIdleTimeout()
Returns the idle timeout (in milliseconds) for ThreadPool.PooledThreads to
 exit. | 
 int | 
getMaximumAllowed()
 | 
 int | 
getPooledCount()
 | 
 int | 
getPriority()
Returns the initial priority given to each thread in this ThreadPool. | 
 int | 
getThreadCount()
 | 
 long | 
getTimeout()
Returns the timeout (in milliseconds) for getting ThreadPool.PooledThreads
 from this ThreadPool. | 
private  void | 
init(int max,
     boolean isDaemon)
Initializes this ThreadPool so that it will permit
 only the supplied number of ThreadPool.PooledThreads to exist. | 
 boolean | 
isClosed()
 | 
 void | 
removeThreadPoolListener(ThreadPoolListener listener)
 | 
 void | 
setIdleTimeout(long timeout)
Sets the timeout (in milliseconds) for idle ThreadPool.PooledThreads to
 exit. | 
 void | 
setPriority(int priority)
Sets the priority given to each thread in this ThreadPool. | 
 void | 
setTimeout(long timeout)
Sets the timeout (in milliseconds) for getting ThreadPool.PooledThreads
 from this ThreadPool or for closing this
 ThreadPool. | 
private  Thread[] | 
sort(Thread[] threads)
 | 
 Thread | 
start(Runnable target)
Waits for a ThreadPool.PooledThread to become available and starts a
 Runnable in it. | 
 Thread | 
start(Runnable target,
      long timeout)
Waits for a ThreadPool.PooledThread to become available and starts a
 Runnable in it. | 
 Thread | 
start(Runnable target,
      long timeout,
      String name)
Waits for a ThreadPool.PooledThread to become available and starts a
 Runnable in it. | 
 Thread | 
start(Runnable target,
      String name)
Waits for a ThreadPool.PooledThread to become available and starts a
 Runnable in it. | 
private  Thread | 
start0(Runnable target,
       long timeout,
       String name)
 | 
private  ThreadPool.PooledThread | 
startThread(Runnable target,
            String name)
 | 
(package private)  void | 
threadAvailable(ThreadPool.PooledThread thread)
 | 
(package private)  void | 
threadExiting(ThreadPool.PooledThread thread)
 | 
| Methods inherited from class java.lang.ThreadGroup | 
activeCount, activeGroupCount, add, add, allowThreadSuspension, checkAccess, destroy, enumerate, enumerate, enumerate, enumerate, enumerate, enumerate, getMaxPriority, getName, getParent, interrupt, isDaemon, isDestroyed, list, list, parentOf, remove, remove, resume, setDaemon, setMaxPriority, stop, stopOrSuspend, suspend, toString, uncaughtException | 
| Methods inherited from class java.lang.Object | 
 | 
| Field Detail | 
private static int threadID
ThreadPool.PooledThread names.private long timeout
ThreadPool.PooledThreads
  out of this ThreadPool.  Any negative value is
  taken to indicate infinity.private long idleTimeout
ThreadPool.PooledThreads in this
  ThreadPool should wait before aging off.  Any
  negative value is taken to indicate infinity.private final Collection listeners
Collection of ThreadPoolListeners that are
  alerted when ThreadPool.PooledThreads become available and leave this
  ThreadPool.private LinkedList pool
LinkedList of ThreadPool.PooledThreads that
  are idling and ready to perform a job.  Although this field is a
  LinkedList, it is used for its stack-like features.private int max
ThreadPool.PooledThreads allowed.  At no point
  should the number of ThreadPool.PooledThreads in the pool exceed this
  number.private int active
ThreadPool.PooledThreads in this
  ThreadPool.  A ThreadPool.PooledThread is active for
  this purpose if it is either pooled and idling or running a
  job.private boolean isDaemon
ThreadPool.PooledThreads in this
  ThreadPool should be created as daemon ThreadPool.PooledThreads.private int priority
ThreadPool.PooledThreads in this
  ThreadPool.private boolean isClosed
ThreadPool is closed.| Constructor Detail | 
public ThreadPool(String name,
                  int max)
           throws IllegalArgumentException
ThreadPool of daemon ThreadPool.PooledThreads.name - the name of the new ThreadPoolmax - the maximum allowed number of ThreadPool.PooledThreadsIllegalArgumentException - if max < 0
public ThreadPool(ThreadGroup parent,
                  String name,
                  int max)
           throws IllegalArgumentException
ThreadPool of daemon ThreadPool.PooledThreads.parent - the parent ThreadGroupname - the name of the new ThreadPoolmax - the maximum allowed number of ThreadPool.PooledThreadsIllegalArgumentException - if max < 0
public ThreadPool(String name,
                  int max,
                  boolean isDaemon)
           throws IllegalArgumentException
ThreadPool.name - the name of the new ThreadPoolmax - the maximum allowed number of ThreadPool.PooledThreadsisDaemon - if true, all ThreadPool.PooledThreads in this
 ThreadPool will be daemon
 ThreadPool.PooledThreads.IllegalArgumentException - if max < 0
public ThreadPool(ThreadGroup parent,
                  String name,
                  int max,
                  boolean isDaemon)
           throws IllegalArgumentException
ThreadPool.parent - the parent ThreadGroupname - the name of the new ThreadPoolmax - the maximum allowed number of ThreadPool.PooledThreadsisDaemon - if true, all ThreadPool.PooledThreads in this
 ThreadPool will be daemon
 ThreadPool.PooledThreadsIllegalArgumentException - if max < 0| Method Detail | 
private final void init(int max,
                        boolean isDaemon)
                 throws IllegalArgumentException
ThreadPool so that it will permit
 only the supplied number of ThreadPool.PooledThreads to exist.max - the maximum allowed number of ThreadPool.PooledThreadsisDaemon - if true, all ThreadPool.PooledThreads in this
 ThreadPool will be daemon
 ThreadPool.PooledThreadsIllegalArgumentException - if max < 0public void setTimeout(long timeout)
ThreadPool.PooledThreads
 from this ThreadPool or for closing this
 ThreadPool. A negative value specifies an infinite
 timeout.  Calling the start(Runnable, long) method (or
 any variation that takes a timeout argument) will
 override this setting.timeout - the new timeout valuepublic long getTimeout()
ThreadPool.PooledThreads
 from this ThreadPool.  The default value is
 negative, which indicates an infinite wait.public void setIdleTimeout(long timeout)
ThreadPool.PooledThreads to
 exit. A negative value specifies that an idle thread never exits.public long getIdleTimeout()
ThreadPool.PooledThreads to
 exit. The default value is negative, which indicates that idle
 ThreadPool.PooledThreads never exit.public void addThreadPoolListener(ThreadPoolListener listener)
public void removeThreadPoolListener(ThreadPoolListener listener)
public int getPriority()
ThreadPool. The default value is that of the thread
 that created this ThreadPool.
public void setPriority(int priority)
                 throws IllegalArgumentException
ThreadPool.IllegalArgumentException - if priority is out of rangepublic int getMaximumAllowed()
ThreadPool.PooledThreads.public int getAvailableCount()
ThreadPool.PooledThreads in this
 ThreadPool.public int getPooledCount()
ThreadPool.PooledThreads in this
 ThreadPool that are either available or in use.public int getThreadCount()
ThreadPool.PooledThreads in this
 ThreadGroup.  Delegates internally by
 default to the activeCount()
 method.public Thread[] getAllThreads()
ThreadGroupprivate Thread[] sort(Thread[] threads)
public Thread start(Runnable target)
             throws NoThreadException,
                    InterruptedException
ThreadPool.PooledThread to become available and starts a
 Runnable in it.  If there are no available ThreadPool.PooledThreads and the number of active ThreadPool.PooledThreads is less than
 the maximum allowed, then a newly created thread is returned.target - the Runnable instance that gets started by
 the returned ThreadPool.PooledThreadThreadPool.PooledThread that has been started on the given 
 Runnable.NoThreadException - if no ThreadPool.PooledThread could be obtained.InterruptedException - if interrupted while waiting for a
 ThreadPool.PooledThread to become available
public Thread start(Runnable target,
                    long timeout)
             throws NoThreadException,
                    InterruptedException
ThreadPool.PooledThread to become available and starts a
 Runnable in it.  If there are no available ThreadPool.PooledThreads and the number of active ThreadPool.PooledThreads is less than
 the maximum allowed, then a newly created ThreadPool.PooledThread is returned.target - the Runnable instance that gets started by
 the returned thread.timeout - milliseconds to wait for a ThreadPool.PooledThread to become
 available. If zero, don't wait at all. If negative, wait forever.ThreadPool.PooledThread that has been started on the given 
 Runnable.NoThreadException - If no ThreadPool.PooledThread could be obtained.InterruptedException - If interrupted while waiting for a
 ThreadPool.PooledThread to become available.
public Thread start(Runnable target,
                    String name)
             throws NoThreadException,
                    InterruptedException
ThreadPool.PooledThread to become available and starts a
 Runnable in it.  If there are no available ThreadPool.PooledThreads and the number of active ThreadPool.PooledThreads is less than
 the maximum allowed, then a newly created ThreadPool.PooledThread is returned.target - the Runnable instance that gets started by
 the returned ThreadPool.PooledThreadname - the name to give the ThreadPool.PooledThreadThreadPool.PooledThread that has been started on the given
 Runnable.NoThreadException - if no ThreadPool.PooledThread could be obtained.InterruptedException - if interrupted while waiting for a
 ThreadPool.PooledThread to become available.
public Thread start(Runnable target,
                    long timeout,
                    String name)
             throws NoThreadException,
                    InterruptedException
ThreadPool.PooledThread to become available and starts a
 Runnable in it.  If there are no available ThreadPool.PooledThreads and the number of active ThreadPool.PooledThreads is less than
 the maximum allowed, then a newly created ThreadPool.PooledThread is
 returned.target - the Runnable instance that gets started by
 the returned ThreadPool.PooledThreadtimeout - milliseconds to wait for a ThreadPool.PooledThread to become
 available. If zero, don't wait at all. If negative, wait forever.name - the name to give the ThreadPool.PooledThreadThreadPool.PooledThread that has been started on the given
 Runnable.NoThreadException - if no ThreadPool.PooledThread could be obtainedInterruptedException - if interrupted while waiting for a
 ThreadPool.PooledThread to become available.
private Thread start0(Runnable target,
                      long timeout,
                      String name)
               throws NoThreadException,
                      InterruptedException
public boolean isClosed()
public void close()
           throws InterruptedException
ThreadPool.PooledThreads in this
 ThreadPool as they become available. This method may
 block forever if any ThreadPool.PooledThreads are never returned to this
 ThreadPool.
public void close(long timeout)
           throws InterruptedException
ThreadPool.PooledThreads in this
 ThreadPool as they become available. If all the
 ThreadPool.PooledThreads cannot become available within the specified
 timeout, any active ThreadPool.PooledThreads not yet returned to this
 ThreadPool are interrupted.timeout - milliseconds to wait before unavailable ThreadPool.PooledThreads
 are interrupted. If zero, don't wait at all. If negative, wait forever.
private ThreadPool.PooledThread startThread(Runnable target,
                                            String name)
private void ensureOpen()
                 throws ThreadPoolClosedException
void threadAvailable(ThreadPool.PooledThread thread)
void threadExiting(ThreadPool.PooledThread thread)
  | 
foundry-0.9.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||