| java.lang.Object org.zkoss.util.ScalableTimer
ScalableTimer | public class ScalableTimer (Code) | | A facility for threads to schedule tasks for future execution in
a background thread.
It has the same function as
Timer , but it is scalable by use of
a collection of
Timer . Use
ScalableTimer if you want to
schedule a lot of tasks.
However, it doesn't support repeated execution.
author: tomyeh since: 3.0.1 |
Constructor Summary | |
public | ScalableTimer(int cTimers, int threshold) Creates a scalable timer. |
Method Summary | |
public void | cancel() Terminates this timer, discarding any currently scheduled tasks. | public int | getMaxTimerSize() Returns the maximal allowed number of timers (
Timer )
are used in this instance. | public int | getThreshold() Returns the threshold, i.e., the allowed number of tasks to be
scheduled for a timer, before starting a new timer. | public void | schedule(ScalableTimerTask task, long delay) Schedules the specified task for execution after the specified delay. | public void | schedule(ScalableTimerTask task, Date time) Schedules the specified task for execution at the specified time. |
ScalableTimer | public ScalableTimer(int cTimers, int threshold)(Code) | | Creates a scalable timer.
Note: no real timer (thread) is created until the first task
being scheduled.
Parameters: cTimers - the maximal allowed number of timers to use.1 is assumed if nonpositive. Parameters: threshold - the threshold, i.e., the number of tasks allowed tobe scheduled for a timer before creating additional timer.1 is assumed if nonpositive.Note: if the number of scheduled task exceeds the capacity(ScalableTimer.getMaxTimerSize * ScalableTimer.getThreshold), the tasks are distributed evenlyover all timers |
cancel | public void cancel()(Code) | | Terminates this timer, discarding any currently scheduled tasks.
This method may be called repeatedly; the second and subsequent calls have no effect.
|
getMaxTimerSize | public int getMaxTimerSize()(Code) | | Returns the maximal allowed number of timers (
Timer )
are used in this instance.
|
getThreshold | public int getThreshold()(Code) | | Returns the threshold, i.e., the allowed number of tasks to be
scheduled for a timer, before starting a new timer.
|
schedule | public void schedule(ScalableTimerTask task, long delay)(Code) | | Schedules the specified task for execution after the specified delay.
Parameters: task - task to be scheduled. Parameters: delay - delay in milliseconds before task is to be executed. |
schedule | public void schedule(ScalableTimerTask task, Date time)(Code) | | Schedules the specified task for execution at the specified time.
Parameters: task - task to be scheduled. Parameters: time - time at which task is to be executed. |
|
|