de.cau.cs.kieler.sim.kiem.execution
Class TimeoutThread
java.lang.Object
java.lang.Thread
de.cau.cs.kieler.sim.kiem.execution.TimeoutThread
- All Implemented Interfaces:
- Runnable
public class TimeoutThread
- extends Thread
The Class TimeoutThread. It is used to handle timeouts of methods implemented by DataComponents
during the execution. An instance of this class is designed to run in a concurrent worker thread.
Whenever the timeout method is called the timeout is activated.
There are two possibilities to stop or deactivate the timeout when the component finished in
time:
1. set another new timeout by calling timeout(int, String, DataComponentWrapper, Execution)
again.
2. reset the timeout by calling abortTimeout()
.
When a timeout is triggered then an error message is generated and the execution is stopped
immediately. Note that the execution manager only tries to stop all concurrent threads but cannot
guarantee that they really terminate in the end.
If a timeout is triggered and the execution is stopped, the timeout thread itself also
terminates.
A timeout must be at least 100ms (reasonable).
- Rating

- (2009-01-15)
Constructor Summary |
TimeoutThread()
Instantiates a new timeout 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 |
TimeoutThread
public TimeoutThread()
- Instantiates a new timeout thread.
timeout
public void timeout(int timeoutParam,
String jobDescriptionParam,
DataComponentWrapper dataComponentWrapperParam,
Execution executionParam)
- Activate as a new timeout. The jobDescription should hold information about the called
methods of the DataComponentWrapper.
- Parameters:
timeoutParam
- the timeout in msjobDescriptionParam
- the job descriptiondataComponentWrapperParam
- the affected DataComponentWrapperexecutionParam
- a link to the execution
abortTimeout
public void abortTimeout()
- Abort a timeout. This aborts the current timeout. Another way to abort a timeout is to simply
set a new one by calling the method
timeout(int, String, DataComponentWrapper, Execution)
.
terminate
public void terminate()
- Terminates this thread by awaking it (if it is suspended). The
run()
method will
terminate if it sees the terminate
flag to be true.
run
public void run()
- Specified by:
run
in interface Runnable
- Overrides:
run
in class Thread