class EvictionTimer
extends java.lang.Object
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.
Modifier and Type | Class and Description |
---|---|
private static class |
EvictionTimer.PrivilegedGetTccl
PrivilegedAction used to get the ContextClassLoader |
private static class |
EvictionTimer.PrivilegedSetTccl
PrivilegedAction used to set the ContextClassLoader |
Modifier and Type | Field and Description |
---|---|
private static java.util.Timer |
_timer
Timer instance
|
private static int |
_usageCount
Static usage count tracker
|
Modifier | Constructor and Description |
---|---|
private |
EvictionTimer()
Prevent instantiation
|
Modifier and Type | Method and Description |
---|---|
(package private) static void |
cancel(java.util.TimerTask task)
Remove the specified eviction task from the timer.
|
(package private) static void |
schedule(java.util.TimerTask task,
long delay,
long period)
Add the specified eviction task to the timer.
|
private static java.util.Timer _timer
private static int _usageCount
static void schedule(java.util.TimerTask task, long delay, long period)
cancel(TimerTask)
to cancel the
task to prevent memory and/or thread leaks in application server
environments.task
- Task to be scheduleddelay
- Delay in milliseconds before task is executedperiod
- Time in milliseconds between executionsstatic void cancel(java.util.TimerTask task)
task
- Task to be scheduled