Package org.apache.commons.pool2.impl
Class EvictionTimer
- java.lang.Object
-
- org.apache.commons.pool2.impl.EvictionTimer
-
class EvictionTimer extends java.lang.ObjectProvides a shared idle object eviction timer for all pools. This class wraps the standardTimerand 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.
This class is intended to be thread-safe.
- Since:
- 2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classEvictionTimer.PrivilegedGetTcclPrivilegedActionused to get the ContextClassLoaderprivate static classEvictionTimer.PrivilegedNewEvictionTimerPrivilegedActionused to create a new Timer.private static classEvictionTimer.PrivilegedSetTcclPrivilegedActionused to set the ContextClassLoader
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Timer_timerTimer instanceprivate static int_usageCountStatic usage count tracker
-
Constructor Summary
Constructors Modifier Constructor Description privateEvictionTimer()Prevent instantiation
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static voidcancel(java.util.TimerTask task)Remove the specified eviction task from the timer.(package private) static voidschedule(java.util.TimerTask task, long delay, long period)Add the specified eviction task to the timer.
-
-
-
Method Detail
-
schedule
static void schedule(java.util.TimerTask task, long delay, long period)Add the specified eviction task to the timer. Tasks that are added with a call to this method *must* callcancel(TimerTask)to cancel the task to prevent memory and/or thread leaks in application server environments.- Parameters:
task- Task to be scheduleddelay- Delay in milliseconds before task is executedperiod- Time in milliseconds between executions
-
cancel
static void cancel(java.util.TimerTask task)
Remove the specified eviction task from the timer.- Parameters:
task- Task to be scheduled
-
-