Agent System POND 1.2 (28.2.2002)

FIM.Util.Threads
Class Timer

java.lang.Object
  |
  +--FIM.Util.Threads.Timer
All Implemented Interfaces:
Serializable

public final class Timer
extends Object
implements Serializable

A timer, which can be set for recurring or once calling a number of listeners. The timer can be serialized and will be created exactly as it was serialized, including a new Thread for waiting if the serialized version was running (elapsed time is reset although).

Version:
1.0, 1.7.2000
Author:
Michael Sonntag
See Also:
TimerAction, Serialized Form

Constructor Summary
Timer(long secondsToWait)
          Create a new timer for a certain period which occurs once.
Timer(long secondsToWait, boolean recurring)
          Create a new timer for a certain period, which might be recurring.
 
Method Summary
 void addTickListener(TimerAction ta)
          Adds a new listener for this timer.
 long getID()
          Returns the ID of this timer.
 long getInterval()
          Returns the interval of the timer (Complete time, not the remaining one!).
 void removeTickListener(TimerAction ta)
          emoves a listener for this timer.
 void setInterval(long newInterval)
          Sets the interval of the timer.
 void startTimer()
          Starts the timer.
 void stopTimer()
          Stops the timer.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Timer

public Timer(long secondsToWait,
             boolean recurring)
Create a new timer for a certain period, which might be recurring. The timer will not be started.
Parameters:
secondsToWait - number of seconds till (or between) the event
recurring - if true the timer will be restarted automatically after notifying all listeners

Timer

public Timer(long secondsToWait)
Create a new timer for a certain period which occurs once. The timer will not be started.
Parameters:
secondsToWait - number of seconds till (or between) the event
Method Detail

getID

public long getID()
Returns the ID of this timer.
Returns:
the ID of this timer

startTimer

public void startTimer()
Starts the timer.

stopTimer

public void stopTimer()
Stops the timer.

getInterval

public long getInterval()
Returns the interval of the timer (Complete time, not the remaining one!).
Returns:
the interval of the timer

setInterval

public void setInterval(long newInterval)
Sets the interval of the timer. If the timer is currently running, it is stopped and restarted with the new interval.

addTickListener

public void addTickListener(TimerAction ta)
Adds a new listener for this timer.
Parameters:
ta - the listener to add

removeTickListener

public void removeTickListener(TimerAction ta)
emoves a listener for this timer.
Parameters:
ta - the listener to remove

Agent System POND 1.2 (28.2.2002)

Submit a bug

Copyright 2001,2002 Michael Sonntag & Institute for Information Processing and Microprocessor Technology (FIM), Johannes-Kepler-University Linz, Altenbergerstr. 69, A-4040 Linz, Austria.