Scheduler based on JDK's ScheduledThreadPoolExecutor.
While use of ScheduledThreadPoolExecutor creates futures that will not be used,
it has the advantage of allowing to set a property to remove cancelled tasks from its
queue even if the task did not fire, which provides a huge benefit in the performance
of garbage collection in young generation.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final ClassLoader | |
| private final AtomicInteger | |
| private final boolean | |
| private final String | |
| private volatile ScheduledExecutorService | |
| private volatile Thread | |
| private final ThreadGroup | |
| private final int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | |
| public | |
| public | ScheduledExecutorScheduler(String name, boolean daemon, ClassLoader classLoader, ThreadGroup threadGroup)
|
| public | ScheduledExecutorScheduler(String
The name of the scheduler threads or null for automatic name name, boolean True if scheduler threads should be daemon daemon, ClassLoader The classloader to run the threads with or null to use the current thread context classloader classLoader, ThreadGroup The threadgroup to use or null for no thread group threadGroup, int The number of threads to pass to the core threads)ScheduledExecutorService or -1 for a
heuristic determined number of threads.
|
| public | ScheduledExecutorScheduler(ScheduledExecutorService
the core scheduledExecutorService)ScheduledExecutorService to be used
|
| Modifier and Type | Method and Description |
|---|---|
| protected void | doStart()
Overrides org. |
| protected void | doStop()
Overrides org. |
| public String | |
| public void | dump(Appendable
The appendable to dump to out, String The indent to apply after any new lines. indent)Implements org. |
| public String | |
| public int | |
| public boolean | |
| public Scheduler. | schedule(Runnable task, long delay, TimeUnit unit)
Implements org. |
| classloader | back to summary |
|---|---|
| private final ClassLoader classloader | |
| count | back to summary |
|---|---|
| private final AtomicInteger count | |
| daemon | back to summary |
|---|---|
| private final boolean daemon | |
| name | back to summary |
|---|---|
| private final String name | |
| scheduler | back to summary |
|---|---|
| private volatile ScheduledExecutorService scheduler | |
| thread | back to summary |
|---|---|
| private volatile Thread thread | |
| threadGroup | back to summary |
|---|---|
| private final ThreadGroup threadGroup | |
| threads | back to summary |
|---|---|
| private final int threads | |
| ScheduledExecutorScheduler | back to summary |
|---|---|
| public ScheduledExecutorScheduler() | |
| ScheduledExecutorScheduler | back to summary |
|---|---|
| public ScheduledExecutorScheduler(String name, boolean daemon) | |
| ScheduledExecutorScheduler | back to summary |
|---|---|
| public ScheduledExecutorScheduler(String name, boolean daemon, int threads) | |
| ScheduledExecutorScheduler | back to summary |
|---|---|
| public ScheduledExecutorScheduler(String name, boolean daemon, ClassLoader classLoader) | |
| ScheduledExecutorScheduler | back to summary |
|---|---|
| public ScheduledExecutorScheduler(String name, boolean daemon, ClassLoader classLoader, ThreadGroup threadGroup) | |
| ScheduledExecutorScheduler | back to summary |
|---|---|
public ScheduledExecutorScheduler(String name, boolean daemon, ClassLoader classLoader, ThreadGroup threadGroup, int threads)
| |
| ScheduledExecutorScheduler | back to summary |
|---|---|
public ScheduledExecutorScheduler(ScheduledExecutorService scheduledExecutorService)
| |
| doStart | back to summary |
|---|---|
| protected void doStart() throws Exception Overrides org. Doc from org. Method to override to start the lifecycle | |
| doStop | back to summary |
|---|---|
| protected void doStop() throws Exception Overrides org. Doc from org. Method to override to stop the lifecycle | |
| dump | back to summary |
|---|---|
| public String dump() Overrides default org.
| |
| dump | back to summary |
|---|---|
| public void dump(Appendable out, String indent) throws IOException Implements org. Doc from org. Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.
| |
| getName | back to summary |
|---|---|
public String getName()
| |
| getThreads | back to summary |
|---|---|
public int getThreads()
| |
| isDaemon | back to summary |
|---|---|
public boolean isDaemon()
| |
| schedule | back to summary |
|---|---|
| public Scheduler. Implements org.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final ScheduledFuture |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean |
| scheduledFuture | back to summary |
|---|---|
| private final ScheduledFuture<?> scheduledFuture | |
| ScheduledFutureTask | back to summary |
|---|---|
| pack-priv ScheduledFutureTask(ScheduledFuture<?> scheduledFuture) | |
| cancel | back to summary |
|---|---|
| public boolean cancel() Implements org.
| |