public abstract class TimedTask extends Object implements Runnable, Comparable<TimedTask>, AsyncTask
Modifier and Type | Field and Description |
---|---|
protected boolean |
cancelled |
protected Runnable |
exitHandler |
protected InterruptHandle |
interruptHook |
protected long |
nextRuntime |
protected long |
period |
Constructor and Description |
---|
TimedTask() |
Modifier and Type | Method and Description |
---|---|
boolean |
calculateNextRuntime() |
void |
cancel() |
void |
cancel(boolean interrupt)
Prevents this task from being scheduled again, optionally interrupting the
task if it is currently running.
|
int |
compareTo(TimedTask o) |
long |
getPeriod()
Gets the period of the task, and when it should be run next
|
boolean |
isCancelled()
Returns true if the task has been cancelled or is expired.
|
boolean |
isDue(long time) |
long |
nextRuntime()
Gets the time in which the task will be run.
|
void |
setExitHandler(Runnable runnable)
Sets the task that should be run after all executions of this task have
completed.
|
void |
setPeriod(long period)
Sets the period in which the task should be run next
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isFinished
protected volatile long nextRuntime
protected volatile long period
protected volatile boolean cancelled
protected volatile InterruptHandle interruptHook
protected volatile Runnable exitHandler
public long getPeriod()
public void setPeriod(long period)
period
- public void cancel()
public long nextRuntime()
public void cancel(boolean interrupt)
AsyncTask
cancel
in interface AsyncTask
interrupt
- if true, and this task is presently being executed,
Thread.interrupt()
will be called on the thread currently
executing this task.public boolean isCancelled()
isCancelled
in interface AsyncTask
public boolean calculateNextRuntime()
public boolean isDue(long time)
public void setExitHandler(Runnable runnable)
AsyncTask
setExitHandler
in interface AsyncTask
runnable
- the logic to execute when this task has completed all of its
executions, either because it completed normally, by throwing an
exception, or because it was cancelled by a call to
AsyncTask.cancel(boolean)
.public int compareTo(TimedTask o)
compareTo
in interface Comparable<TimedTask>
Copyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.