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.
ThreadPool
The pool has zero Thread
s 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).
Constructor and Description |
---|
ZeroSizeThreadPool()
Create a new
ZeroSizeThreadPool . |
Modifier and Type | Method and Description |
---|---|
int |
blockForAvailableThreads()
Determines the number of threads that are currently available in in
the pool.
|
org.apache.commons.logging.Log |
getLog() |
int |
getPoolSize() |
void |
initialize()
Called by the QuartzScheduler before the
ThreadPool is
used, in order to give the it a chance to initialize. |
boolean |
runInThread(java.lang.Runnable runnable)
Execute the given
in the next
available Thread . |
void |
shutdown() |
void |
shutdown(boolean waitForJobsToComplete)
Called by the QuartzScheduler to inform the
ThreadPool
that it should free up all of it's resources because the scheduler is
shutting down. |
public org.apache.commons.logging.Log getLog()
public int getPoolSize()
getPoolSize
in interface ThreadPool
public void initialize() throws SchedulerConfigException
ThreadPool
Called by the QuartzScheduler before the ThreadPool
is
used, in order to give the it a chance to initialize.
initialize
in interface ThreadPool
SchedulerConfigException
public void shutdown()
public void shutdown(boolean waitForJobsToComplete)
ThreadPool
Called by the QuartzScheduler to inform the ThreadPool
that it should free up all of it's resources because the scheduler is
shutting down.
shutdown
in interface ThreadPool
public boolean runInThread(java.lang.Runnable runnable)
ThreadPool
Execute the given
in the next
available Runnable
Thread
.
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 false
should be returned.
runInThread
in interface ThreadPool
public int blockForAvailableThreads()
ThreadPool
Determines 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.
blockForAvailableThreads
in interface ThreadPool