org.apache.commons.pool.impl
class: EvictionTimer [javadoc |
source]
java.lang.Object
org.apache.commons.pool.impl.EvictionTimer
Provides a shared idle object eviction timer for all pools. This class wraps
the standard Timer and keeps track of how many pools are using it.
If no pools are using the timer, it is canceled. This prevents a thread
being left running which, in application server environments, can lead to
memory leads and/or prevent applications from shutting down or reloading
cleanly.
This class has package scope to prevent its inclusion in the pool public API.
The class declaration below should *not* be changed to public.
| Method from org.apache.commons.pool.impl.EvictionTimer Summary: |
|---|
|
cancel, schedule |
| Method from org.apache.commons.pool.impl.EvictionTimer Detail: |
static synchronized void cancel(TimerTask task) {
task.cancel();
_usageCount--;
if (_usageCount == 0) {
_timer.cancel();
_timer = null;
}
}
Remove the specified eviction task from the timer. |
static synchronized void schedule(TimerTask task,
long delay,
long period) {
if (null == _timer) {
_timer = new Timer(true);
}
_usageCount++;
_timer.schedule(task, delay, period);
}
Add the specified eviction task to the timer. Tasks that are added with a
call to this method *must* call #cancel(TimerTask) to cancel the
task to prevent memory and/or thread leaks in application server
environments. |