org.quartz.simpl
Class SimpleThreadPool

java.lang.Object
  extended byorg.quartz.simpl.SimpleThreadPool
All Implemented Interfaces:
ThreadPool

public class SimpleThreadPool
extends Object
implements ThreadPool

This is class is a simple implementation of a thread pool, based on the ThreadPool interface.

Runnable objects are sent to the pool with the runInThread(Runnable) method, which blocks until a Thread becomes available.

The pool has a fixed number of Threads, and does not grow or shrink based on demand.

Author:
James House, Juergen Donnerstag

Constructor Summary
SimpleThreadPool()
           Create a new (unconfigured) SimpleThreadPool.
SimpleThreadPool(int threadCount, int threadPriority)
           Create a new SimpleThreadPool with the specified number of Thread s that have the given priority.
 
Method Summary
protected  org.quartz.simpl.SimpleThreadPool.WorkerThread[] createWorkerThreads(int count)
           
 org.apache.commons.logging.Log getLog()
           
 int getPoolSize()
           
 int getThreadCount()
           Get the number of worker threads in the pool.
 String getThreadNamePrefix()
           
 int getThreadPriority()
           Get the thread priority of worker threads in the pool.
 void initialize()
           Called by the QuartzScheduler before the ThreadPool is used, in order to give the it a chance to initialize.
 boolean isMakeThreadsDaemons()
           
 boolean isThreadsInheritContextClassLoaderOfInitializingThread()
           
 boolean isThreadsInheritGroupOfInitializingThread()
           
 boolean runInThread(Runnable runnable)
           Run the given Runnable object in the next available Thread.
 void setMakeThreadsDaemons(boolean makeThreadsDaemons)
           
 void setThreadCount(int count)
           Set the number of worker threads in the pool - has no effect after initialize() has been called.
 void setThreadNamePrefix(String prfx)
           
 void setThreadPriority(int prio)
           Set the thread priority of worker threads in the pool - has no effect after initialize() has been called.
 void setThreadsInheritContextClassLoaderOfInitializingThread(boolean inheritLoader)
           
 void setThreadsInheritGroupOfInitializingThread(boolean inheritGroup)
           
 void shutdown()
           Terminate any worker threads in this thread group.
 void shutdown(boolean waitForJobsToComplete)
           Terminate any worker threads in this thread group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleThreadPool

public SimpleThreadPool()

Create a new (unconfigured) SimpleThreadPool.

See Also:
setThreadCount(int), setThreadPriority(int)

SimpleThreadPool

public SimpleThreadPool(int threadCount,
                        int threadPriority)

Create a new SimpleThreadPool with the specified number of Thread s that have the given priority.

Parameters:
threadCount - the number of worker Threads in the pool, must be > 0.
threadPriority - the thread priority for the worker threads.
See Also:
Thread
Method Detail

getLog

public org.apache.commons.logging.Log getLog()

getPoolSize

public int getPoolSize()
Specified by:
getPoolSize in interface ThreadPool

setThreadCount

public void setThreadCount(int count)

Set the number of worker threads in the pool - has no effect after initialize() has been called.


getThreadCount

public int getThreadCount()

Get the number of worker threads in the pool.


setThreadPriority

public void setThreadPriority(int prio)

Set the thread priority of worker threads in the pool - has no effect after initialize() has been called.


getThreadPriority

public int getThreadPriority()

Get the thread priority of worker threads in the pool.


setThreadNamePrefix

public void setThreadNamePrefix(String prfx)

getThreadNamePrefix

public String getThreadNamePrefix()

isThreadsInheritContextClassLoaderOfInitializingThread

public boolean isThreadsInheritContextClassLoaderOfInitializingThread()
Returns:
Returns the threadsInheritContextClassLoaderOfInitializingThread.

setThreadsInheritContextClassLoaderOfInitializingThread

public void setThreadsInheritContextClassLoaderOfInitializingThread(boolean inheritLoader)
Parameters:
inheritLoader - The threadsInheritContextClassLoaderOfInitializingThread to set.

isThreadsInheritGroupOfInitializingThread

public boolean isThreadsInheritGroupOfInitializingThread()

setThreadsInheritGroupOfInitializingThread

public void setThreadsInheritGroupOfInitializingThread(boolean inheritGroup)

isMakeThreadsDaemons

public boolean isMakeThreadsDaemons()
Returns:
Returns the value of makeThreadsDaemons.

setMakeThreadsDaemons

public void setMakeThreadsDaemons(boolean makeThreadsDaemons)
Parameters:
makeThreadsDaemons - The value of makeThreadsDaemons to set.

initialize

public void initialize()
                throws SchedulerConfigException
Description copied from interface: ThreadPool

Called by the QuartzScheduler before the ThreadPool is used, in order to give the it a chance to initialize.

Specified by:
initialize in interface ThreadPool
Throws:
SchedulerConfigException

createWorkerThreads

protected org.quartz.simpl.SimpleThreadPool.WorkerThread[] createWorkerThreads(int count)

shutdown

public void shutdown()

Terminate any worker threads in this thread group.

Jobs currently in progress will complete.


shutdown

public void shutdown(boolean waitForJobsToComplete)

Terminate any worker threads in this thread group.

Jobs currently in progress will complete.

Specified by:
shutdown in interface ThreadPool

runInThread

public boolean runInThread(Runnable runnable)

Run the given Runnable object in the next available Thread. If while waiting the thread pool is asked to shut down, the Runnable is executed immediately within a new additional thread.

Specified by:
runInThread in interface ThreadPool
Parameters:
runnable - the Runnable to be added.

Quartz Enterprise Job Scheduler Project Page