public class ExecuteWatchdog extends java.lang.Object implements TimeoutObserver
限定符和类型 | 字段和说明 |
---|---|
static long |
INFINITE_TIMEOUT
The marker for an infinite timeout
|
构造器和说明 |
---|
ExecuteWatchdog(long timeout)
Creates a new watchdog with a given timeout.
|
限定符和类型 | 方法和说明 |
---|---|
void |
checkException()
This method will rethrow the exception that was possibly caught during
the run of the process.
|
void |
destroyProcess()
Destroys the running process manually.
|
boolean |
isWatching()
Indicates whether or not the watchdog is still monitoring the process.
|
boolean |
killedProcess()
Indicates whether the last process run was killed.
|
void |
start(java.lang.Process process)
Watches the given process and terminates it, if it runs for too long.
|
void |
stop()
Stops the watcher.
|
void |
timeoutOccured(Watchdog w)
Called after watchdog has finished.
|
public static final long INFINITE_TIMEOUT
public ExecuteWatchdog(long timeout)
timeout
- the timeout for the process in milliseconds. It must be
greater than 0 or 'INFINITE_TIMEOUT'public void start(java.lang.Process process)
process
- the process to monitor. It cannot be nulljava.lang.IllegalStateException
- if a process is still being monitored.public void stop()
public void destroyProcess()
public void timeoutOccured(Watchdog w)
timeoutOccured
在接口中 TimeoutObserver
w
- the watchdog that timed out.public void checkException() throws java.lang.Exception
java.lang.Exception
- a wrapped exception over the one that was silently swallowed
and stored during the process run.public boolean isWatching()
public boolean killedProcess()