jmce - 1_02

jmce.util
Class TimerManager

java.lang.Object
  extended by java.lang.Thread
      extended by jmce.util.TimerManager
All Implemented Interfaces:
java.lang.Runnable

public class TimerManager
extends java.lang.Thread

Timer manager for Timer.

Like java.util.TimerTask but it is possible to change the base time and make timer based on every unit of time. The default implementation is for time milliseconds based. To create a TimerManager in any other time unit the method elapsed() must be called at regular interval with a number of unit time elapsed as parameter.

For performance reason the Timer are inserted in one double linked list managed from the TimerManager itelf. Method are non sincronized so be carefully if used from more than one thread.

Version:
1.02
Author:
Mario Viara
See Also:
Timer

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TimerManager(java.lang.String name)
          Standard constructor
 
Method Summary
 void add(Timer t)
          Add a timer to the queue.
static void addTimer(Timer t)
          Add a new timer to the standard timer queue.
 void elapsed(int n)
          Called to advance the queue
 int getSize()
          Return the number of timer queued.
 void remove(Timer t)
          Remove a timer from the queue.
 void run()
          Thread to manage the standard ms based timer manager.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimerManager

public TimerManager(java.lang.String name)
Standard constructor

Method Detail

getSize

public final int getSize()
Return the number of timer queued.


addTimer

public static void addTimer(Timer t)
Add a new timer to the standard timer queue.


add

public final void add(Timer t)
Add a timer to the queue.


remove

public final void remove(Timer t)
Remove a timer from the queue.


elapsed

public final void elapsed(int n)
                   throws SIMException
Called to advance the queue

Throws:
SIMException

run

public void run()
Thread to manage the standard ms based timer manager.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Thread

jmce - 1_02