org.directwebremoting.util
Class StaticTimer

java.lang.Object
  extended by org.directwebremoting.util.StaticTimer

public class StaticTimer
extends java.lang.Object

A Timer can manage many TimerTasks, but each Timer requires a new thread to operate, so it makes more sense to share a Timer amongst man TimerTasks.

There are a number of things that this class does not do that it perhaps should, for example, to count the number of outstanding tasks, and to drop the thread when there are none, however in a server using reverse ajax it is likely that there will be another one soon, and a lightly loaded server is not in need of careful thread management.

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Field Summary
protected static java.util.Timer timer
          The shared Timer
 
Constructor Summary
StaticTimer()
           
 
Method Summary
static void schedule(java.util.TimerTask task, java.util.Date time)
          Schedules the specified task for execution at the specified time.
static void schedule(java.util.TimerTask task, java.util.Date firstTime, long period)
          Schedules the specified task for repeated fixed-delay execution, beginning at the specified time.
static void schedule(java.util.TimerTask task, long delay)
          Schedules the specified task for execution after the specified delay.
static void schedule(java.util.TimerTask task, long delay, long period)
          Schedules the specified task for repeated fixed-delay execution, beginning after the specified delay.
static void scheduleAtFixedRate(java.util.TimerTask task, java.util.Date firstTime, long period)
          Schedules the specified task for repeated fixed-rate execution, beginning at the specified time.
static void scheduleAtFixedRate(java.util.TimerTask task, long delay, long period)
          Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timer

protected static java.util.Timer timer
The shared Timer

Constructor Detail

StaticTimer

public StaticTimer()
Method Detail

schedule

public static void schedule(java.util.TimerTask task,
                            long delay)
Schedules the specified task for execution after the specified delay.

Parameters:
task - task to be scheduled.
delay - delay in milliseconds before task is to be executed.
See Also:
Timer.schedule(TimerTask, long)

schedule

public static void schedule(java.util.TimerTask task,
                            java.util.Date time)
Schedules the specified task for execution at the specified time. If the time is in the past, the task is scheduled for immediate execution.

Parameters:
task - task to be scheduled.
time - time at which task is to be executed.
See Also:
Timer.schedule(TimerTask, Date)

schedule

public static void schedule(java.util.TimerTask task,
                            long delay,
                            long period)
Schedules the specified task for repeated fixed-delay execution, beginning after the specified delay. Subsequent executions take place at approximately regular intervals separated by the specified period.

Parameters:
task - task to be scheduled.
delay - delay in milliseconds before task is to be executed.
period - time in milliseconds between successive task executions.
See Also:
Timer.schedule(TimerTask, long, long)

schedule

public static void schedule(java.util.TimerTask task,
                            java.util.Date firstTime,
                            long period)
Schedules the specified task for repeated fixed-delay execution, beginning at the specified time. Subsequent executions take place at approximately regular intervals, separated by the specified period.

Parameters:
task - task to be scheduled.
firstTime - First time at which task is to be executed.
period - time in milliseconds between successive task executions.
See Also:
Timer.schedule(TimerTask, Date, long)

scheduleAtFixedRate

public static void scheduleAtFixedRate(java.util.TimerTask task,
                                       long delay,
                                       long period)
Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay. Subsequent executions take place at approximately regular intervals, separated by the specified period.

Parameters:
task - task to be scheduled.
delay - delay in milliseconds before task is to be executed.
period - time in milliseconds between successive task executions.
See Also:
Timer.scheduleAtFixedRate(TimerTask, Date, long)

scheduleAtFixedRate

public static void scheduleAtFixedRate(java.util.TimerTask task,
                                       java.util.Date firstTime,
                                       long period)
Schedules the specified task for repeated fixed-rate execution, beginning at the specified time. Subsequent executions take place at approximately regular intervals, separated by the specified period.

Parameters:
task - task to be scheduled.
firstTime - First time at which task is to be executed.
period - time in milliseconds between successive task executions.
See Also:
Timer.scheduleAtFixedRate(TimerTask, Date, long)