jarol
Class TimeTrigger

java.lang.Object
  extended by java.lang.Thread
      extended by jarol.TimeTrigger
All Implemented Interfaces:
TimeTriggerInterface, java.lang.Runnable

public class TimeTrigger
extends java.lang.Thread
implements TimeTriggerInterface

TimeTrigger is a periodic signal that provides timing.

Version:
0.1
Author:
Bernhard Kast

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
TimeTrigger(int period)
          Allocates a new TimeTrigger with the given period.
TimeTrigger(int period, boolean debug)
          Allocates a new TimeTrigger with the given period and the debug flag.
 
Method Summary
 void await()
          Causes the calling task to be suspended until the period is finished.
 int getPeriod()
          Returns the current period.
 void run()
          Performs the sleeping and waking up.
 void setPeriod(int period)
          Sets the period in milliseconds.
 void stopExecution()
          Stops the execution of the thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, 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, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeTrigger

public TimeTrigger(int period)
Allocates a new TimeTrigger with the given period.

Parameters:
period - - The period in milliseconds.

TimeTrigger

public TimeTrigger(int period,
                   boolean debug)
Allocates a new TimeTrigger with the given period and the debug flag.

Parameters:
period - - The period in milliseconds.
debug - - Print debug information.
Method Detail

await

public void await()
           throws AwaitDuringSignalingException
Causes the calling task to be suspended until the period is finished.

Specified by:
await in interface TimeTriggerInterface
Throws:
AwaitDuringSignalingException

setPeriod

public void setPeriod(int period)
Sets the period in milliseconds.

Specified by:
setPeriod in interface TimeTriggerInterface
Parameters:
period - - The period in milliseconds.

getPeriod

public int getPeriod()
Returns the current period.

Specified by:
getPeriod in interface TimeTriggerInterface
Returns:
- The current period in milliseconds.

run

public void run()
Performs the sleeping and waking up.

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

stopExecution

public void stopExecution()
Stops the execution of the thread.

Specified by:
stopExecution in interface TimeTriggerInterface