- Enclosing class:
public final class TimerManager.Timer
- extends java.lang.Object
This class describes a single timer object and allows to start, stop and destroy the timer.
The timer object can be created using the
createTimer method of
Note that after the applet finishes using a timer object, it should call the
method in order to release system resources used by this timer object.
Since the system resources required for running a timer are shared between all running applications,
it is possible that a call to the
start method will fail by throwing
UtilOutOfResourcesException. This means that there are no more resources
available in the system for starting this timer, and the application should retry to start
it at later time.
This method destroys the timer.
This method check for timer running state.
This method starts the timer created by
This method stops the timer.
|Methods inherited from class java.lang.Object|
public void start(int ticks, byte userData, int index, int length, boolean auto) throws UtilException
- This method starts the timer created by
TimerManager.createTimermethod. This method must be called on idle (stopped or new created) timer only, otherwise IllegalUseException will be thrown. Starting timer using destroyed Timer object [after Timer.destroy()] will throw NotInitializedException. Ticks value should be positive (large than zero), otherwise IllegalParameterException is thrown. User data may be 'null'.
ticks- number of milliseconds per timer shot
userData- byte array to be passed to
TimerClient.onTimerTickmethod on timer expiration
index- non-negative index in the userDate buffer which indicates where userData starts
length- non-negative total length of userData
auto- auto restart on expire (periodic timer)
UtilException- exception when general failure occurs
IllegalParameterException- exception when method parameters are illegal
NotInitializedException- exception when using Timer object after destroy() method was called
IllegalUseException- exception when trying to start already started timer.
UtilOutOfResourcesException- exception when system is out of resources
public void stop() throws UtilException
- This method stops the timer.
This method can be called on running or already stopped timer,
no exception will be thrown.
If trying to call this method after the destroy() method was executed,
will throw NotInitializedException.
public void destroy() throws UtilException
- This method destroys the timer.
Timer may be idle (stopped) or running. The running timer will be stopped and then destroyed.
This method should be called after the applet finishes using this timer object. (to free native resources)
If this method called twice (or more), will throw NotInitializedException.
After execution of this method, the Timer object became not-initialized and calling timer
methods (start/stop/destroy) will cause NotInitializedException.
public boolean isRunning()
- This method check for timer running state.
- true - timer is running. false - otherwise.