public interface Scheduler {
//--- General operation ---
// Terminates the scheduler:
void shutdown() throws Exception;
//--- Execute a runnable in another thread ---
// Immediately executes a {@code Runnable} in the worker thread pool:
void execute(Runnable runnable);
// Executes the Runnable in a newly-created thread:
Thread startThread(String name, boolean daemon, Runnable runnable);
//--- Scheduled callbacks ---
// Schedules a Runnable that is executed "delay" number of msec in the future:
ScheduledFuture<?> scheduleCallback(Runnable command, long delay);
// Schedules a Runnable that is executed in the future after some number of random msec:
ScheduledFuture<?> scheduleCallback(Runnable command, long delay, double min, double max);
// Schedules a Runnable that is executed at the specified Date:
ScheduledFuture<?> scheduleCallback(Runnable command, Date date);
//--- Recurring callbacks ---
// Schedules a Runnable that is executed on a recurring basis (option 1):
ScheduledFuture<?> scheduleCallbackAtFixedRate(Runnable command, long initialDelay, long period);
// Schedules a Runnable that is executed on a recurring basis (option 2):
ScheduledFuture<?> scheduleCallbackAtFixedRate(Runnable command, Date date, long period);
// Schedules a Runnable that is executed on a recurring basis (option 3):
ScheduledFuture<?> scheduleCallbackWithFixedDelay(Runnable command, long initialDelay, long delay);
//--- Convenience ---
// Wrapper for Thread.sleep() with default exception handling:
void sleep(long msec);
//--- Executor services and thread factory ---
// Returns the *primary* worker thread pool executor:
ExecutorService getWorkerThreadPool();
// Returns the *scheduled* thread pool executor:
ScheduledThreadPoolExecutor getScheduledThreadPool();
// Returns a ThreadFactory that names new threads based on the provided "name":
ThreadFactory getNamedThreadFactory(String name);
}