Java Reference
In-Depth Information
MemoryWatchTask extends the abstract TimerTask to define a task that
prints the current free and total memory, prefixed by the current time.
TimerTask implements the Runnable interface, and its run method is what
is invoked by a Timer object when a task is to be run. Because the setup
code told timer to execute once a second, the thread used by timer will
wait one second between task executions.
TimerTask has three methods:
public abstract void run()
Defines the action to be performed by this TimerTask .
public boolean cancel()
Cancels this TimerTask so that it will never run again (or at all
if it hasn't run yet). Returns true if the task was scheduled
for repeated execution or was a once-only task that had not
yet been run. Returns false if the task was a once-only task
that has already run, the task was never scheduled, or the
task has previously been cancelled. Essentially, this method
returns true if it prevented the task from having a scheduled
execution.
public long scheduledExecutionTime()
Returns the scheduled execution time of the most recent ac-
tual execution (possibly the in-progress execution) of this
TimerTask . The returned value represents the time in milli-
seconds. This method is most often used inside run to see if
the current execution of the task occurred soon enough to
warrant execution; if the task was delayed too long run may
decide not to do anything.
 
Search WWH ::




Custom Search