<?xml version="1.0"?>

<document>

 <properties>
  <title>Overview</title>
  <author email="dev@commons.apache.org">Commons Documentation Team</author>
 </properties>

 <body>

<section name="The ThreadPool Component">
      <p>
        Commons ThreadPool is a component for working with pools of threads and asynchronously executing
        tasks.
      </p>
      <p>
        Often inside application servers and containers the threading model is managed for you.
        However in some circumstances it can be useful to use your own worker thread pools to dispatch
        asynchronous work into. 
      </p>
      <p>
      	In enterprise class systems typically JMS is used to perform some task asynchronously by another machine.
        However ThreadPools can be a simple and effective mechanism for asynchronous processing within the same process. 
        This can be particularly useful for performing asynchronous processing in
        Servlet engines or Swing applications.
      </p>
      <p>
        Please note that one of the reasons this component is still in the sandbox and has
        never had a 1.0 release is Doug Lea's excellent
        <a href="http://gee.cs.oswego.edu/dl">util.concurrent library</a>.  That library 
        works with many JDKs, is full-featured, well-documented, and well-tested.  That
        library is also a standard part of the JDK starting with JDK 1.5, as the
        java.util.concurrent library: it is specified in the
        <a href="http://www.jcp.org/en/jsr/detail?id=166">JSR 166 standard.</a>
        <br />
        All of this is not to say commons-sandbox-threadpool is useless.  As with most
        Apache products, the development and release of this component is driven by
        user requests and developer interest.
      </p>
</section>

<section name="Releases">
    <p>
       See the <a href="downloads.html">downloads</a> page for information on obtaining releases.
    </p>
</section>

<section name="Documentation">
  <p>
     The <a href="apidocs/index.html">JavaDoc API documents</a> are available online.
  </p>
</section>

    <section name="How to use a ThreadPool">

      <p>
        Once you have a ThreadPool instance you can invoke functionality asynchronously
        on a ThreadPool via the invokeLater() method.
      </p>

<source>
  // lets start with 5 threads
  ThreadPool threadPool = new DefaultThreadPool(5);    	
	
  // lets use a specific Runnable
  Runnable someTask = ...;
  threadPool.invokeLater( someTask );
	
  // lets just wrap up some code in a Runnable
  threadPool.invokeLater(
    new Runnable() {
      public void run() {
        someObject.doSomeSlowThing();
      }
    }		
  );	
</source>
				 
      <p>
        Note that inside the run() method of your Runnable object you must handle Exceptions properly.
        Any unhandled runtime exception will be caught and logged using Commons Logging.
      </p>
    </section>

</body>
</document>
