TimerTask


TimerTask java.util

Java 1.3 runnable

This abstract Runnable class represents a task that is scheduled with a Timer object for one-time or repeated execution in the future. You can define a task by subclassing TimerTask and implementing the abstract run( ) method. Schedule the task for future execution by passing an instance of your subclass to one of the schedule( ) or scheduleAtFixedRate( ) methods of Timer . The Timer object will then invoke the run( ) method at the scheduled time or times.

Call cancel( ) to cancel the one-time or repeated execution of a TimerTask( ) . This method returns TRue if a pending execution was actually canceled . It returns false if the task has already been canceled, was never scheduled, or was scheduled for one-time execution and has already been executed. scheduledExecutionTime( ) returns the time in milliseconds at which the most recent execution of the TimerTask was scheduled to occur. When the host system is heavily loaded, the run( ) method may not be invoked exactly when scheduled. Some tasks may choose to do nothing if they are not invoked on time. The run( ) method can compare the return values of scheduledExecutionTime( ) and System.currentTimeMillis( ) to determine whether the current invocation is sufficiently timely .

Figure 16-60. java.util.TimerTask

 public abstract class  TimerTask  implements Runnable {  // Protected Constructors  protected  TimerTask  ( );  // Public Instance Methods  public boolean  cancel  ( );        public long  scheduledExecutionTime  ( );  // Methods Implementing Runnable  public abstract void  run  ( );   } 

Passed To

Timer.{schedule( ) , scheduleAtFixedRate( )}



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net