org.apache.qpid.test.framework.clocksynch
Class ClockSynchThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.apache.qpid.test.framework.clocksynch.ClockSynchThread
All Implemented Interfaces:
Runnable, org.apache.qpid.junit.extensions.ShutdownHookable

public class ClockSynchThread
extends Thread
implements org.apache.qpid.junit.extensions.ShutdownHookable

ClockSynchThread is a convenient utility for running a thread that periodically synchronizes the clock against a reference. Supply it with a ClockSynchronizer and a Throttle and it will continually keep the clock up-to-date at a rate determined by the throttle.

CRC Card
Responsibilities Collaborations
Continually sychronize the clock at a throttled rate.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
(package private)  boolean doSynch
          Flag to indicate that the periodic clock syncher should keep running.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ClockSynchThread(ClockSynchronizer syncher, org.apache.qpid.junit.extensions.Throttle throttle)
          Creates a clock synchronizer thread from a clock synchronizer and a throttle.
 
Method Summary
 ClockSynchronizer getClockSyncher()
          Gets the clock synchronizer that is kept continually up to date.
 Thread getShutdownHook()
          Supplies a shutdown hook, that terminates the synching thread.
 void run()
          Continually updates the clock, until terminate() is called.
 void terminate()
          Terminates the synchronization 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
 

Field Detail

doSynch

boolean doSynch
Flag to indicate that the periodic clock syncher should keep running.

Constructor Detail

ClockSynchThread

public ClockSynchThread(ClockSynchronizer syncher,
                        org.apache.qpid.junit.extensions.Throttle throttle)
Creates a clock synchronizer thread from a clock synchronizer and a throttle.

Parameters:
syncher - The clock synchronizer.
throttle - The throttle.
Method Detail

terminate

public void terminate()
Terminates the synchronization thread.


run

public void run()
Continually updates the clock, until terminate() is called.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

getClockSyncher

public ClockSynchronizer getClockSyncher()
Gets the clock synchronizer that is kept continually up to date.

Returns:
The clock synchronizer that is kept continually up to date.

getShutdownHook

public Thread getShutdownHook()
Supplies a shutdown hook, that terminates the synching thread.

Specified by:
getShutdownHook in interface org.apache.qpid.junit.extensions.ShutdownHookable
Returns:
The shut down hook.


Licensed to the Apache Software Foundation