com.tensegrity.generic.util
Class Timer

java.lang.Object
  extended bycom.tensegrity.generic.util.Timer
All Implemented Interfaces:
java.lang.Runnable

public class Timer
extends java.lang.Object
implements java.lang.Runnable

The Timer class provides a way to execute a Runnable when the end of a fixed period has been reached. The periods are divided into the first period after the Timer has been started and all periods that follow.

Version:
$Id: Timer.java,v 1.9 2005/11/18 11:49:39 KevinCVS Exp $
Author:
MichaelKegel

Constructor Summary
Timer()
          Constructor for Timer.
 
Method Summary
 java.lang.Thread getThread()
          Returns the Thread the Timer runs within.
 boolean hasStopped()
          Returns a flag which indicates that the Timer has been stopped.
 void run()
           
protected  void start()
          Starts the Thread belonging to this Timer -object.
 void start(java.lang.Runnable runnable, int initialPeriod, int period)
          This method has to be called to start the Timer.
 void stop()
          This method has to be called to stop 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()
Constructor for Timer.

Method Detail

hasStopped

public boolean hasStopped()
Returns a flag which indicates that the Timer has been stopped.

Returns:
true, if the Timer has been stopped.

getThread

public java.lang.Thread getThread()
Returns the Thread the Timer runs within.

Returns:
the Thread this timer belongs to.

start

public void start(java.lang.Runnable runnable,
                  int initialPeriod,
                  int period)
This method has to be called to start the Timer. The method run() of the given Runnable is called whenever the end of a period has been reached.

Parameters:
runnable - the Runnable to start whenever the end of a period has been reached.
initialPeriod - the delay in milliseconds for the first period after the timer has been started.
period - the delay in milliseconds for all periods without the first after the timer has been started.

Find more information in the class documentation


stop

public void stop()
This method has to be called to stop the Timer.


start

protected void start()
Starts the Thread belonging to this Timer -object.


run

public void run()
Specified by:
run in interface java.lang.Runnable


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.