public class ScheduledExecutor extends Object implements RejectedExecutionHandler
ScheduledThreadPoolExecutor
, to
be used for f.i. job polling.Modifier and Type | Class and Description |
---|---|
(package private) static class |
ScheduledExecutor.MyThreadFactory |
Modifier and Type | Field and Description |
---|---|
private ScheduledThreadPoolExecutor |
executor
The executor, to be created lazily.
|
private HashMap<Runnable,Future<?>> |
map |
private static ScheduledExecutor |
scheduledExecutor |
Modifier | Constructor and Description |
---|---|
private |
ScheduledExecutor(int size) |
Modifier and Type | Method and Description |
---|---|
private void |
addJob(Runnable r,
long delay) |
private void |
addJob(Runnable r,
long initialDelay,
long delay) |
private void |
cancel(Runnable r) |
static void |
end()
Ends the executor.Typically called when the OctopusEngine ends.
|
void |
rejectedExecution(Runnable r,
ThreadPoolExecutor executor) |
static void |
remove(Runnable r)
Removes and cancels the specified task from the executor.
|
static void |
schedule(Runnable r,
long delay)
Creates and executes a delayed action that becomes enabled first after
the given delay.
|
static void |
schedule(Runnable r,
long initialDelay,
long delay)
Creates and executes a periodic action that becomes enabled first after
the given initial delay, and subsequently with the given delay between
the termination of one execution and the commencement of the next.
|
private void |
shutdown() |
private ScheduledThreadPoolExecutor executor
private static ScheduledExecutor scheduledExecutor
public static void schedule(Runnable r, long initialDelay, long delay)
r
- the task to run repeatedly.initialDelay
- the time to delay first executiondelay
- the delay between executionspublic static void schedule(Runnable r, long delay)
r
- the task to run..delay
- the delay until the execution.private void addJob(Runnable r, long initialDelay, long delay)
private void addJob(Runnable r, long delay)
private void shutdown()
public static void end()
private void cancel(Runnable r)
public static void remove(Runnable r)
r
- the task to remove.public void rejectedExecution(Runnable r, ThreadPoolExecutor executor)
rejectedExecution
in interface RejectedExecutionHandler