com.javageeks.thread
Class PeriodicThread

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--com.javageeks.thread.PeriodicThread
All Implemented Interfaces:
java.lang.Runnable

public class PeriodicThread
extends java.lang.Thread

PeriodicThread is a specific type of Thread that fires off its associated Runnable evry interval milliseconds.


Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
PeriodicThread(java.lang.Runnable r, int interval)
          Constructor taking the Runnable whose run method we wish to call every interval milliseconds.
 
Method Summary
 int getInterval()
           
static void main(java.lang.String[] args)
          Test driver for the PeriodicThread component
 void run()
          The run method spins in an infinite loop, calling run on the owned Runnable instance every interval milliseconds (as specified in the constructor).
 void setInterval(int interval)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, 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

PeriodicThread

public PeriodicThread(java.lang.Runnable r,
                      int interval)
Constructor taking the Runnable whose run method we wish to call every interval milliseconds.
Method Detail

getInterval

public int getInterval()

setInterval

public void setInterval(int interval)

run

public void run()
The run method spins in an infinite loop, calling run on the owned Runnable instance every interval milliseconds (as specified in the constructor). The time spent in the Runnable's run method is not taken into account in the period spent sleeping.
Overrides:
run in class java.lang.Thread

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Test driver for the PeriodicThread component