Package org.eclipse.jetty.util.thread
Class ScheduledExecutorScheduler
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.thread.ScheduledExecutorScheduler
-
@ManagedObject public class ScheduledExecutorScheduler extends AbstractLifeCycle implements Scheduler, Dumpable
Implementation ofSchedulerbased on JDK'sScheduledThreadPoolExecutor.While use of
ScheduledThreadPoolExecutorcreates 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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Scheduler
Scheduler.Task
-
-
Constructor Summary
Constructors Constructor Description ScheduledExecutorScheduler()ScheduledExecutorScheduler(java.lang.String name, boolean daemon)ScheduledExecutorScheduler(java.lang.String name, boolean daemon, int threads)ScheduledExecutorScheduler(java.lang.String name, boolean daemon, java.lang.ClassLoader classLoader)ScheduledExecutorScheduler(java.lang.String name, boolean daemon, java.lang.ClassLoader classLoader, java.lang.ThreadGroup threadGroup)ScheduledExecutorScheduler(java.lang.String name, boolean daemon, java.lang.ClassLoader classLoader, java.lang.ThreadGroup threadGroup, int threads)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoStart()protected voiddoStop()java.lang.Stringdump()voiddump(java.lang.Appendable out, java.lang.String indent)Dump this object (and children) into an Appendable using the provided indent after any new lines.java.lang.StringgetName()intgetThreads()booleanisDaemon()Scheduler.Taskschedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
-
-
-
Constructor Detail
-
ScheduledExecutorScheduler
public ScheduledExecutorScheduler()
-
ScheduledExecutorScheduler
public ScheduledExecutorScheduler(java.lang.String name, boolean daemon)
-
ScheduledExecutorScheduler
public ScheduledExecutorScheduler(@Name("name") java.lang.String name, @Name("daemon") boolean daemon, @Name("threads") int threads)
-
ScheduledExecutorScheduler
public ScheduledExecutorScheduler(java.lang.String name, boolean daemon, java.lang.ClassLoader classLoader)
-
ScheduledExecutorScheduler
public ScheduledExecutorScheduler(java.lang.String name, boolean daemon, java.lang.ClassLoader classLoader, java.lang.ThreadGroup threadGroup)
-
ScheduledExecutorScheduler
public ScheduledExecutorScheduler(@Name("name") java.lang.String name, @Name("daemon") boolean daemon, @Name("classLoader") java.lang.ClassLoader classLoader, @Name("threadGroup") java.lang.ThreadGroup threadGroup, @Name("threads") int threads)
- Parameters:
name- The name of the scheduler threads or null for automatic namedaemon- True if scheduler threads should be daemonclassLoader- The classloader to run the threads with or null to use the current thread context classloaderthreadGroup- The threadgroup to use or null for no thread groupthreads- The number of threads to pass to the the coreScheduledThreadPoolExecutoror -1 for a heuristic determined number of threads.
-
-
Method Detail
-
doStart
protected void doStart() throws java.lang.Exception- Overrides:
doStartin classAbstractLifeCycle- Throws:
java.lang.Exception
-
doStop
protected void doStop() throws java.lang.Exception- Overrides:
doStopin classAbstractLifeCycle- Throws:
java.lang.Exception
-
schedule
public Scheduler.Task schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit)
-
dump
public void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOExceptionDescription copied from interface:DumpableDump 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
@ManagedAttribute("The name of the scheduler") public java.lang.String getName()
-
isDaemon
@ManagedAttribute("Whether the scheduler uses daemon threads") public boolean isDaemon()
-
getThreads
@ManagedAttribute("The number of scheduler threads") public int getThreads()
-
-