info.ephyra.util
Class TimerThread

java.lang.Object
  extended by java.lang.Thread
      extended by info.ephyra.util.TimerThread
All Implemented Interfaces:
java.lang.Runnable

public class TimerThread
extends java.lang.Thread

A TimerThread interrupts another thread after a timeout has occurred.

Version:
2007-02-03
Author:
Nico Schlaefer

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  java.lang.Thread threadToTimeout
          Threat to be interrupted.
private  long timeout
          Timeout in milliseconds.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TimerThread(long timeout, java.lang.Thread threadToTimeout)
          Sets the timeout and starts the timer.
 
Method Summary
 void run()
          Waits for the time specified in timeout and then interrupts threadToTimeout.
 
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

timeout

private long timeout
Timeout in milliseconds.


threadToTimeout

private java.lang.Thread threadToTimeout
Threat to be interrupted.

Constructor Detail

TimerThread

public TimerThread(long timeout,
                   java.lang.Thread threadToTimeout)
Sets the timeout and starts the timer.

Parameters:
timeout - the timeout in milliseconds
threadToTimeout - the thread to be interrupted
Method Detail

run

public void run()
Waits for the time specified in timeout and then interrupts threadToTimeout.

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