org.apache.jcs.utils.threads
Class ThreadPoolManager

java.lang.Object
  extended byorg.apache.jcs.utils.threads.ThreadPoolManager

public class ThreadPoolManager
extends java.lang.Object

Provides a singleton thread pool.


Method Summary
static ThreadPoolManager getInstance()
          Returns the singleton thread pool manager, which can be used to execute a given IThreadPoolRunnable on a thread in the pool.
static int getMaxSpareThreads()
          Gets the max number of idle threads that you can leave in the pool.
static int getMaxThreads()
          Gets the max number of threads that you can open in the pool.
static int getMinSpareThreads()
          Gets the min number of idle threads that you can leave in the pool.
static void reset()
          Shuts down the thread pool and re-initializes it to the default.
 void runIt(IThreadPoolRunnable r)
          Executes a given IThreadPoolRunnable on a thread in the pool, block if needed.
static void setMaxSpareThreads(int maxSpareThreads)
          Sets the max number of idle threads that you can leave in the pool.
static void setMaxThreads(int maxThreads)
          Sets the max number of threads that you can open in the pool.
static void setMinSpareThreads(int minSpareThreads)
          Sets the min number of idle threads that you can leave in the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setMaxThreads

public static void setMaxThreads(int maxThreads)
Sets the max number of threads that you can open in the pool. Will only be effective if called before the getInstance method is invoked for the first time.

Parameters:
maxThreads - The new maxThreads value

setMinSpareThreads

public static void setMinSpareThreads(int minSpareThreads)
Sets the min number of idle threads that you can leave in the pool. Will only be effective if called before the getInstance method is invoked for the first time.

Parameters:
minSpareThreads - The new minSpareThreads value

setMaxSpareThreads

public static void setMaxSpareThreads(int maxSpareThreads)
Sets the max number of idle threads that you can leave in the pool. Will only be effective if called before the getInstance method is invoked for the first time.

Parameters:
maxSpareThreads - The new maxSpareThreads value

getMaxThreads

public static int getMaxThreads()
Gets the max number of threads that you can open in the pool. Will only be accurate if called after the getInstance method is invoked for the first time.

Returns:
The maxThreads value

getMinSpareThreads

public static int getMinSpareThreads()
Gets the min number of idle threads that you can leave in the pool. Will only be accurate if called after the getInstance method is invoked for the first time.

Returns:
The minSpareThreads value

getMaxSpareThreads

public static int getMaxSpareThreads()
Gets the max number of idle threads that you can leave in the pool. Will only be accurate if called after the getInstance method is invoked for the first time.

Returns:
The maxSpareThreads value

getInstance

public static ThreadPoolManager getInstance()
Returns the singleton thread pool manager, which can be used to execute a given IThreadPoolRunnable on a thread in the pool. Configuration of the thread pool must be made prior to invoking this method.

Returns:
The instance value

reset

public static void reset()
Shuts down the thread pool and re-initializes it to the default.


runIt

public void runIt(IThreadPoolRunnable r)
Executes a given IThreadPoolRunnable on a thread in the pool, block if needed.



Copyright © 2002-2005 Apache Software Foundation. All Rights Reserved.