Name

java.util.Timer

Synopsis

This class defines a facility for threads to schedule tasks for future execution in a background thread. There are four versions of the schedule() method; each schedules tasks to execute at a specific time using a Date object or after a specific delay in milliseconds. The scheduleAtFixedrate() method can be used to schedule tasks for repeated execution in intervals relative to the scheduled execution time of the first execution. If an execution is delayed for any reason (such as garbage collection or other background activity), two or more subsequent executions are scheduled at shorter intervals to catch up.

public classTimer {
   // public constructors
   public Timer();
   // public instance methods
   public void cancel();
   public void schedule(TimerTask task, Date time);
   public void schedule(TimerTask task, long delay);
   public void schedule(TimerTask task, Date firstTime, long period);
   public void schedule(TimerTask task, long delay, long period);
   public void scheduleAtFixedRate(TimerTask task, Date firstTime, long period);
   public void scheduleAtFixedRate(TimerTask task, long delay, long period);
}

Get Wireless Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.