Class ZeroSizeThreadPool
- java.lang.Object
-
- org.quartz.simpl.ZeroSizeThreadPool
-
- All Implemented Interfaces:
ThreadPool
public class ZeroSizeThreadPool extends java.lang.Object implements ThreadPool
This is class is a simple implementation of a zero size thread pool, based on the
interface.ThreadPoolThe pool has zero
Threads and does not grow or shrink based on demand. Which means it is obviously not useful for most scenarios. When it may be useful is to prevent creating any worker threads at all - which may be desirable for the sole purpose of preserving system resources in the case where the scheduler instance only exists in order to schedule jobs, but which will never execute jobs (e.g. will never have start() called on it).- Author:
- Wayne Fay
-
-
Constructor Summary
Constructors Constructor Description ZeroSizeThreadPool()Create a newZeroSizeThreadPool.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intblockForAvailableThreads()Determines the number of threads that are currently available in in the pool.org.slf4j.LoggergetLog()intgetPoolSize()Get the current number of threads in theThreadPool.voidinitialize()Must be called before theThreadPoolis used, in order to give the it a chance to initialize.booleanrunInThread(java.lang.Runnable runnable)Execute the givenin the next availableRunnableThread.voidsetInstanceId(java.lang.String schedInstId)Inform theThreadPoolof the Scheduler instance's Id, prior to initialize being invoked.voidsetInstanceName(java.lang.String schedName)Inform theThreadPoolof the Scheduler instance's name, prior to initialize being invoked.voidshutdown()voidshutdown(boolean waitForJobsToComplete)Called by the QuartzScheduler to inform theThreadPoolthat it should free up all of it's resources because the scheduler is shutting down.
-
-
-
Method Detail
-
getLog
public org.slf4j.Logger getLog()
-
getPoolSize
public int getPoolSize()
Description copied from interface:ThreadPoolGet the current number of threads in the
ThreadPool.- Specified by:
getPoolSizein interfaceThreadPool
-
initialize
public void initialize() throws SchedulerConfigExceptionDescription copied from interface:ThreadPoolMust be called before the
ThreadPoolis used, in order to give the it a chance to initialize.Typically called by the
SchedulerFactory.- Specified by:
initializein interfaceThreadPool- Throws:
SchedulerConfigException
-
shutdown
public void shutdown()
-
shutdown
public void shutdown(boolean waitForJobsToComplete)
Description copied from interface:ThreadPoolCalled by the QuartzScheduler to inform the
ThreadPoolthat it should free up all of it's resources because the scheduler is shutting down.- Specified by:
shutdownin interfaceThreadPool
-
runInThread
public boolean runInThread(java.lang.Runnable runnable)
Description copied from interface:ThreadPoolExecute the given
in the next availableRunnableThread.The implementation of this interface should not throw exceptions unless there is a serious problem (i.e. a serious misconfiguration). If there are no immediately available threads
falseshould be returned.- Specified by:
runInThreadin interfaceThreadPool- Returns:
- true, if the runnable was assigned to run on a Thread.
-
blockForAvailableThreads
public int blockForAvailableThreads()
Description copied from interface:ThreadPoolDetermines the number of threads that are currently available in in the pool. Useful for determining the number of times
runInThread(Runnable)can be called before returning false.The implementation of this method should block until there is at least one available thread.
- Specified by:
blockForAvailableThreadsin interfaceThreadPool- Returns:
- the number of currently available threads
-
setInstanceId
public void setInstanceId(java.lang.String schedInstId)
Description copied from interface:ThreadPoolInform the
ThreadPoolof the Scheduler instance's Id, prior to initialize being invoked.- Specified by:
setInstanceIdin interfaceThreadPool
-
setInstanceName
public void setInstanceName(java.lang.String schedName)
Description copied from interface:ThreadPoolInform the
ThreadPoolof the Scheduler instance's name, prior to initialize being invoked.- Specified by:
setInstanceNamein interfaceThreadPool
-
-