org.neo.swarm.util.threads
Class OswegoThreadPool

java.lang.Object
  extended byorg.neo.swarm.util.threads.OswegoThreadPool
All Implemented Interfaces:
ThreadPool

public class OswegoThreadPool
extends java.lang.Object
implements ThreadPool

Uses Doug Lea's PooledExecutor to handle a threadpool. Pool is highly configurable through the construction of the PooledExecutor. It handles blocking thread states and graceful shutdown.

Author:
navery

Constructor Summary
OswegoThreadPool(EDU.oswego.cs.dl.util.concurrent.PooledExecutor pooledExecutor, int min, int max)
           
 
Method Summary
 void execute(java.lang.Runnable unitOfWork)
          Execute a Runnable impl using an internal thread
 int getMaximumPoolSize()
          The max available pool size.
 int getMinimumPoolSize()
          Minimum available pool size.
 int getPoolSize()
          Current number of threads in use.
 void setMaximumPoolSize(int poolSize)
          Set max thread limit, must also support dynamic resizing of the pool.
 void setMinimumPoolSize(int poolSize)
          Set min thread limit.
 void shutdown(int timeout)
          Timeout of 0 kills all threads, pending or executing, Greater values will allow the incoming queue to be processed, however blocked threads may cause an issue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OswegoThreadPool

public OswegoThreadPool(EDU.oswego.cs.dl.util.concurrent.PooledExecutor pooledExecutor,
                        int min,
                        int max)
Method Detail

execute

public void execute(java.lang.Runnable unitOfWork)
             throws java.lang.InterruptedException
Description copied from interface: ThreadPool
Execute a Runnable impl using an internal thread

Specified by:
execute in interface ThreadPool
Parameters:
unitOfWork -
Throws:
java.lang.InterruptedException

getMaximumPoolSize

public int getMaximumPoolSize()
Description copied from interface: ThreadPool
The max available pool size.

Specified by:
getMaximumPoolSize in interface ThreadPool
Returns:

getMinimumPoolSize

public int getMinimumPoolSize()
Description copied from interface: ThreadPool
Minimum available pool size.

Specified by:
getMinimumPoolSize in interface ThreadPool
Returns:

getPoolSize

public int getPoolSize()
Description copied from interface: ThreadPool
Current number of threads in use.

Specified by:
getPoolSize in interface ThreadPool
Returns:

setMaximumPoolSize

public void setMaximumPoolSize(int poolSize)
Description copied from interface: ThreadPool
Set max thread limit, must also support dynamic resizing of the pool.

Specified by:
setMaximumPoolSize in interface ThreadPool
Parameters:
poolSize -

setMinimumPoolSize

public void setMinimumPoolSize(int poolSize)
Description copied from interface: ThreadPool
Set min thread limit.

Specified by:
setMinimumPoolSize in interface ThreadPool
Parameters:
poolSize -

shutdown

public void shutdown(int timeout)
Description copied from interface: ThreadPool
Timeout of 0 kills all threads, pending or executing, Greater values will allow the incoming queue to be processed, however blocked threads may cause an issue. Oswego allows a Blocker handler to be used.

Specified by:
shutdown in interface ThreadPool
Parameters:
timeout -


Copyright © 2001-2004 SWARM-ONE -First Generation (S)calable(W)ide(AR)ea(M)esh. All Rights Reserved.