public abstract class ScheduledTask
extends java.lang.Object
implements java.lang.Runnable, java.io.Serializable
A scheduled task is submitted to the FIFO thread queue wherein the task could potentially be stacked in line behind other queue entries. The task therefore might not execute at the exact scheduled time but could be delayed momentarily while waiting for its turn in the queue.
| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.ScheduledFuture<?> |
ivFuture
The task's scheduled future.
|
private java.lang.String |
ivId
The task's id.
|
private boolean |
ivIsBusy
A flag indicating if the task is busy.
|
private boolean |
ivIsCanceled
A flag indicating if the task has been canceled.
|
private java.lang.String |
ivName
The task's name.
|
private long |
ivRerun
The task's interval between repeated executions (milliseconds).
|
private static long |
serialVersionUID
The class' serialization version id.
|
| Modifier | Constructor and Description |
|---|---|
protected |
ScheduledTask()
The constructor for the abstract scheduled task.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Instructs the scheduled task that it should end its processing as soon
as possible.
|
boolean |
equals(java.lang.Object obj)
Compares the given object to this object and determines if the two are
equal.
|
protected abstract void |
executeTask()
Executes the task's processing.
|
java.util.concurrent.ScheduledFuture<?> |
getFuture()
Returns the task's scheduled future.
|
java.lang.String |
getId()
Returns the task's id.
|
java.lang.String |
getName()
Returns the task's name.
|
java.util.Date |
getNextExecution()
Returns the task's next execution time.
|
long |
getRerun()
Returns the task's interval between repeated executions (milliseconds).
|
boolean |
isBusy()
Answers if the task is currently busy.
|
boolean |
isCanceled()
Answers if the task has been canceled.
|
void |
run()
Runs the scheduled task.
|
void |
setFuture(java.util.concurrent.ScheduledFuture<?> value)
Sets the task's scheduled future.
|
void |
setId(java.lang.String value)
Sets the task's id.
|
void |
setName(java.lang.String value)
Sets the task's name.
|
void |
setRerun(long value)
Sets the task's interval between repeated executions (milliseconds).
|
private static final long serialVersionUID
private java.lang.String ivId
private java.lang.String ivName
private long ivRerun
private java.util.concurrent.ScheduledFuture<?> ivFuture
private boolean ivIsBusy
private boolean ivIsCanceled
protected ScheduledTask()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - (Object) The object to compare with this object.true if the specified object is equal to
this object, otherwise false.public java.lang.String getId()
public void setId(java.lang.String value)
value - (String) The task's id.public java.lang.String getName()
public void setName(java.lang.String value)
value - (String) The task's name.public long getRerun()
public void setRerun(long value)
value - (long) The task's repeat interval.public java.util.concurrent.ScheduledFuture<?> getFuture()
public void setFuture(java.util.concurrent.ScheduledFuture<?> value)
value - (ScheduledFuture) The task's scheduled future.public java.util.Date getNextExecution()
public boolean isBusy()
true if busy, otherwise false.public boolean isCanceled()
true if canceled, otherwise false.public void cancel()
public void run()
Runnable interface.
Subclasses should not override this method.run in interface java.lang.Runnableprotected abstract void executeTask()
isCanceled and attempt to gracefully end processing as
quickly as possible.