## visad.util
Class ThreadPool

    java.lang.Object
      visad.util.ThreadPool

public class ThreadPool
extends Object

A pool of threads (with minimum and maximum limits on the number of threads) which can be used to execute any Runnable tasks.

Constructor Summary
`ThreadPool()` Build a thread pool with the default thread name prefix and the default minimum and maximum numbers of threads
`ThreadPool(int max)` Build a thread pool with the specified maximum number of threads, and the default thread name prefix and minimum number of threads
`ThreadPool(int min, int max)` Build a thread pool with the specified minimum and maximum numbers of threads, and the default thread name prefix
`ThreadPool(String prefix)` Build a thread pool with the specified thread name prefix, and the default minimum and maximum numbers of threads
`ThreadPool(String prefix, int min, int max)` Build a thread pool with the specified thread name prefix and minimum and maximum numbers of threads

Method Summary
`(package private) Runnable` `getTask()` Get the next task on the queue. This method is intended only for the use of client threads and should never be called by external objects.
`boolean` `isTerminated()` Has the thread pool been closed?
`void` `queue(Runnable r)` Add a task to the queue; tasks are executed as soon as a thread is available, in the order in which they are submitted
`(package private) void` `releaseTask(Runnable r)`
`void` `remove(Runnable r)`
`void` `setThreadMaximum(int num)` increase the maximum number of pooled threads
`void` `stopThreads()` Stop all threads as soon as all queued tasks are completed
`boolean` `waitForTasks()` wait for currently-running tasks to finish

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ThreadPool

    public ThreadPool()
               throws Exception

  Build a thread pool with the default thread name prefix and the default minimum and maximum numbers of threads

### ThreadPool

    public ThreadPool(String prefix)
               throws Exception

  Build a thread pool with the specified thread name prefix, and the default minimum and maximum numbers of threads

### ThreadPool

    public ThreadPool(int max)
               throws Exception

  Build a thread pool with the specified maximum number of threads, and the default thread name prefix and minimum number of threads

### ThreadPool

    public ThreadPool(int min,
                      int max)
               throws Exception

  Build a thread pool with the specified minimum and maximum numbers of threads, and the default thread name prefix

### ThreadPool

    public ThreadPool(String prefix,
                      int min,
                      int max)
               throws Exception

  Build a thread pool with the specified thread name prefix and minimum and maximum numbers of threads

Method Detail

### remove

    public void remove(Runnable r)

### isTerminated

    public boolean isTerminated()

  Has the thread pool been closed?

  Returns:
    `true` if the pool has been terminated.

### queue

    public void queue(Runnable r)

  Add a task to the queue; tasks are executed as soon as a thread is available, in the order in which they are submitted

### getTask

    Runnable getTask()

  Get the next task on the queue.
  This method is intended only for the use of client threads and should never be called by external objects.

### releaseTask

    void releaseTask(Runnable r)

### waitForTasks

    public boolean waitForTasks()

  wait for currently-running tasks to finish

### setThreadMaximum

    public void setThreadMaximum(int num)
                          throws Exception

  increase the maximum number of pooled threads

  Throws:
    `Exception`

### stopThreads

    public void stopThreads()

  Stop all threads as soon as all queued tasks are completed