public class ScheduledExecutorScheduler extends AbstractLifeCycle implements Scheduler, Dumpable
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 |
ScheduledExecutorScheduler.ScheduledFutureTask |
AbstractLifeCycle.AbstractLifeCycleListenerScheduler.TaskLifeCycle.Listener| Modifier and Type | Field and Description |
|---|---|
private java.lang.ClassLoader |
classloader |
private boolean |
daemon |
private java.lang.String |
name |
private java.util.concurrent.ScheduledThreadPoolExecutor |
scheduler |
private java.lang.Thread |
thread |
private java.lang.ThreadGroup |
threadGroup |
FAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING| Constructor and Description |
|---|
ScheduledExecutorScheduler() |
ScheduledExecutorScheduler(java.lang.String name,
boolean daemon) |
ScheduledExecutorScheduler(java.lang.String name,
boolean daemon,
java.lang.ClassLoader threadFactoryClassLoader) |
ScheduledExecutorScheduler(java.lang.String name,
boolean daemon,
java.lang.ClassLoader threadFactoryClassLoader,
java.lang.ThreadGroup threadGroup) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doStart() |
protected void |
doStop() |
java.lang.String |
dump() |
void |
dump(java.lang.Appendable out,
java.lang.String indent) |
Scheduler.Task |
schedule(java.lang.Runnable task,
long delay,
java.util.concurrent.TimeUnit unit) |
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, start, stop, stopprivate final java.lang.String name
private final boolean daemon
private final java.lang.ClassLoader classloader
private final java.lang.ThreadGroup threadGroup
private volatile java.util.concurrent.ScheduledThreadPoolExecutor scheduler
private volatile java.lang.Thread thread
public ScheduledExecutorScheduler()
public ScheduledExecutorScheduler(java.lang.String name,
boolean daemon)
public ScheduledExecutorScheduler(java.lang.String name,
boolean daemon,
java.lang.ClassLoader threadFactoryClassLoader)
public ScheduledExecutorScheduler(java.lang.String name,
boolean daemon,
java.lang.ClassLoader threadFactoryClassLoader,
java.lang.ThreadGroup threadGroup)
protected void doStart()
throws java.lang.Exception
doStart in class AbstractLifeCyclejava.lang.Exceptionprotected void doStop()
throws java.lang.Exception
doStop in class AbstractLifeCyclejava.lang.Exceptionpublic Scheduler.Task schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)