suramadu.util.exec
Class PeriodicJavaThread

java.lang.Object
  extended byjava.lang.Thread
      extended bysuramadu.util.exec.PeriodicJavaThread
All Implemented Interfaces:
java.lang.Runnable

public class PeriodicJavaThread
extends java.lang.Thread

Simulates the periodic capabilities of a RealtimeThread and a NoHeapRealtimeThread in the RTSJ. It allows both the period and the priority to be set.

Author:
mbi

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
PeriodicJavaThread(java.lang.Runnable r)
          Creates a new instance of PeriodicJavaThread with the specified Runnable.
PeriodicJavaThread(java.lang.Runnable r, int iterations)
          Creates a new instance of PeriodicJavaThread with the specified Runnable and iteration count.
PeriodicJavaThread(java.lang.Runnable r, long period)
          Creates a new instance of PeriodicJavaThread with the specified Runnable and period.
PeriodicJavaThread(java.lang.Runnable r, long period, int iterations)
          Creates a new instance of PeriodicJavaThread with the specified Runnable, period and iterations.
PeriodicJavaThread(java.lang.Runnable r, long delay, long period)
          Creates a new instance of PeriodicJavaThread with the specified Runnable, initial delay, and period.
PeriodicJavaThread(java.lang.Runnable r, long delay, long period, int iterations)
          Creates a new instance of PeriodicJavaThread with the specified Runnable, initial delay, and period and iterations.
 
Method Summary
 void kill()
          Cancels this PeriodicJavaThread by calling its task's cancel() method.
 void run()
          The run() method for Runnable
 void setDelay(long delay)
          Allows after-construction of the initial delay and period of the thread.
 void setPeriod(long period)
          Allows after-construction of the period of the thread.
 void start()
          Overloads Thread.start().
 
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, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PeriodicJavaThread

public PeriodicJavaThread(java.lang.Runnable r)
Creates a new instance of PeriodicJavaThread with the specified Runnable.

Parameters:
r - The Runnable to execute periodically.

PeriodicJavaThread

public PeriodicJavaThread(java.lang.Runnable r,
                          long period)
Creates a new instance of PeriodicJavaThread with the specified Runnable and period.

Parameters:
r - the Runnable to execute periodically.
period - the period (specified in milliseconds) in which to run.

PeriodicJavaThread

public PeriodicJavaThread(java.lang.Runnable r,
                          long delay,
                          long period)
Creates a new instance of PeriodicJavaThread with the specified Runnable, initial delay, and period.

Parameters:
r - the Runnable to execute periodically.
delay - initial delay before the first period (specified in milliseconds).
period - the period (specified in milliseconds) in which to run.

PeriodicJavaThread

public PeriodicJavaThread(java.lang.Runnable r,
                          int iterations)
Creates a new instance of PeriodicJavaThread with the specified Runnable and iteration count.

Parameters:
r - The Runnable to execute periodically.
iterations - The number of times to repeat a periodic thread.

PeriodicJavaThread

public PeriodicJavaThread(java.lang.Runnable r,
                          long period,
                          int iterations)
Creates a new instance of PeriodicJavaThread with the specified Runnable, period and iterations.

Parameters:
r - the Runnable to execute periodically.
period - the period (specified in milliseconds) in which to run.
iterations - The number of times to repeat a periodic thread.

PeriodicJavaThread

public PeriodicJavaThread(java.lang.Runnable r,
                          long delay,
                          long period,
                          int iterations)
Creates a new instance of PeriodicJavaThread with the specified Runnable, initial delay, and period and iterations.

Parameters:
r - the Runnable to execute periodically.
delay - initial delay before the first period (specified in milliseconds).
period - the period (specified in milliseconds) in which to run.
iterations - The number of times to repeat a periodic thread.
Method Detail

setPeriod

public void setPeriod(long period)
Allows after-construction of the period of the thread.

Parameters:
period - the period (specified in milliseconds) in which to run.

setDelay

public void setDelay(long delay)
Allows after-construction of the initial delay and period of the thread.

Parameters:
delay - initial delay before the first period (specified in milliseconds).

kill

public void kill()
Cancels this PeriodicJavaThread by calling its task's cancel() method.


start

public void start()
Overloads Thread.start(). Handles scheduling with Timer and Timertask.

See Also:
Thread.start()

run

public void run()
The run() method for Runnable