This class is currently implemented using ScheduledThreadPoolExecutor. This implementation may change in any
future release. This class keeps track of how many pools are using it. If no pools are using the timer, it is
cancelled. 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.
| Modifier and Type | Class and Description |
|---|---|
| private static class | EvictionTimer.
Thread factory that creates a daemon thread, with the context class loader from this class. |
| private static class | EvictionTimer.
Task that removes references to abandoned tasks and shuts down the executor if there are no live tasks left. |
| private static class | EvictionTimer.
The kind of Runnable. R extends Runnable>Runnable that runs the referent of a weak reference. |
| Modifier and Type | Field and Description |
|---|---|
| private static ScheduledThreadPoolExecutor | executor
Executor instance |
| private static final HashMap | TASK_MAP
Keys are weak references to tasks, values are runners managed by executor. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static synchronized void | cancel(final BaseGenericObjectPool<?>.
Task to be cancelled. evictor,If the associated executor is no longer required, how
long should this thread wait for the executor to
terminate? timeout, final boolean The state of the evictor. restarting)Removes the specified eviction task from the timer. |
| pack-priv static ScheduledThreadPoolExecutor | |
| pack-priv static synchronized int | |
| pack-priv static HashMap | |
| private static void | remove(final BaseGenericObjectPool<?>.
Eviction task to remove evictorRemoves evictor from the task set and executor. |
| pack-priv static synchronized void | schedule(final BaseGenericObjectPool<?>.
Task to be scheduled. task,Duration before task is executed. delay, final Duration Duration between executions. period)Adds the specified eviction task to the timer. |
| public String |
| executor | back to summary |
|---|---|
| private static ScheduledThreadPoolExecutor executor Executor instance | |
| TASK_MAP | back to summary |
|---|---|
| private static final HashMap<WeakReference<BaseGenericObjectPool<?>. Keys are weak references to tasks, values are runners managed by executor. | |
| EvictionTimer | back to summary |
|---|---|
| private EvictionTimer() Prevents instantiation | |
| cancel | back to summary |
|---|---|
| pack-priv static synchronized void cancel(final BaseGenericObjectPool<?>. Removes the specified eviction task from the timer.
| |
| getExecutor | back to summary |
|---|---|
| pack-priv static ScheduledThreadPoolExecutor getExecutor() For testing only.
| |
| getNumTasks | back to summary |
|---|---|
pack-priv static synchronized int getNumTasks()
| |
| getTaskMap | back to summary |
|---|---|
| pack-priv static HashMap Gets the task map. Keys are weak references to tasks, values are runners managed by executor.
| |
| remove | back to summary |
|---|---|
| private static void remove(final BaseGenericObjectPool<?>. Removes evictor from the task set and executor. Only called when holding the class lock.
| |
| schedule | back to summary |
|---|---|
| pack-priv static synchronized void schedule(final BaseGenericObjectPool<?>. Adds the specified eviction task to the timer. Tasks that are added with
a call to this method *must* call
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Thread | newThread(final Runnable runnable)
Implements java. Constructs a new unstarted |
| EvictorThreadFactory | back to summary |
|---|---|
| private EvictorThreadFactory() | |
| newThread | back to summary |
|---|---|
| public Thread newThread(final Runnable runnable) Implements java. Doc from java. Constructs a new unstarted
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| Reaper | back to summary |
|---|---|
| private Reaper() | |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final WeakReference |
| Access | Constructor and Description |
|---|---|
| private | WeakRunner(final WeakReference<R>
the reference to track. ref)Constructs a new instance to track the given reference. |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| ref | back to summary |
|---|---|
| private final WeakReference<R> ref | |
| WeakRunner | back to summary |
|---|---|
| private WeakRunner(final WeakReference<R> ref) Constructs a new instance to track the given reference.
| |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation.
| |