de.dfki.lt.mary.modules
Class ProcessTimeoutDestroyer

java.lang.Object
  extended by java.lang.Thread
      extended by de.dfki.lt.mary.modules.ProcessTimeoutDestroyer
All Implemented Interfaces:
java.lang.Runnable

public class ProcessTimeoutDestroyer
extends java.lang.Thread

Destroy a given process if timeout occurs. This is used to monitor whether an external module gets stuck.

Author:
Marc Schröder

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
ProcessTimeoutDestroyer(ExternalModule module)
           
 
Method Summary
 boolean didDestroy()
           
 void doWait(long time)
           
 java.lang.Process getProcess()
           
 long getTimeLimit()
           
 void makeSureWereReady()
           
 void pleaseExit()
           
 void resetTimeLimit()
          Reset the time limit to 0.
 void run()
           
 void setTimeLimit(long timeLimit)
          A timelimit > 0 will cause the timeout-destroy procedure to be started.
 
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

ProcessTimeoutDestroyer

public ProcessTimeoutDestroyer(ExternalModule module)
Method Detail

getProcess

public java.lang.Process getProcess()

getTimeLimit

public long getTimeLimit()

setTimeLimit

public void setTimeLimit(long timeLimit)
A timelimit > 0 will cause the timeout-destroy procedure to be started. The thread setting the timelimit will be the only one whose call to resetTimeLimit() is taken into account. If a new thread sets a new time limit while the old one is still running, the old one is silently stopped, and the new one is started as if the old one was not there.

See Also:
resetTimeLimit()

resetTimeLimit

public void resetTimeLimit()
Reset the time limit to 0. Only the thread who initiated the latest time limit can also take it back. If another thread tries to reset the time limit, it is ignored.


pleaseExit

public void pleaseExit()

didDestroy

public boolean didDestroy()

makeSureWereReady

public void makeSureWereReady()

doWait

public void doWait(long time)

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread