com.planeth.common.timing
Class TimedObjectThread

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.planeth.common.timing.TimedObjectThread
All Implemented Interfaces:
java.lang.Runnable

public class TimedObjectThread
extends java.lang.Thread

Thread with a predefined min frameTime
If the thread goes faster than the defined frameTime, it waits until the frametime is reached.

Author:
Andreas Grässer, gal@planet-h.com.
created May 7, 2005
See Also:
IThreadControllable

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TimedObjectThread(IThreadControllable threadControllable)
          Constructor for TimedObjectThread.
TimedObjectThread(IThreadControllable threadControllable, int preferredFrameTime)
          Constructor for TimedObjectThread.
 
Method Summary
static int getActiveThreadCount()
          Returns the complete number of TimedObjectThreads existing
 void run()
           
 void safeStop()
          Triggers a safe stop of the Thread.
static void terminateAllThreads()
          Termitates all TimedObjectThreads (safeStop)
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimedObjectThread

public TimedObjectThread(IThreadControllable threadControllable)
Constructor for TimedObjectThread.

Parameters:
threadControllable - the IThreadControllable to be controlled by the Thread

TimedObjectThread

public TimedObjectThread(IThreadControllable threadControllable,
                         int preferredFrameTime)
Constructor for TimedObjectThread.

Parameters:
threadControllable - the IThreadControllable to be controlled by the Thread
preferredFrameTime - the min frameTime for the Thread
Method Detail

getActiveThreadCount

public static int getActiveThreadCount()
Returns the complete number of TimedObjectThreads existing

Returns:
Returns the complete number of TimedObjectThreads existing

terminateAllThreads

public static void terminateAllThreads()
Termitates all TimedObjectThreads (safeStop)


safeStop

public void safeStop()
Triggers a safe stop of the Thread.
After running safeStop the Thread finishes its current step and terminates after that.


run

public void run()
See Also:
Runnable.run()