Interface IAsynchronousProcess
-
- All Superinterfaces:
IProcess
- All Known Implementing Classes:
AsynchrounousProcess
public interface IAsynchronousProcess extends IProcess
Defines an asynchronous process
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
destroy()
Destroy the process immediate.java.lang.ProcessHandle
getProcessHandle()
Get the process handle.boolean
isAlive()
Check whether the process is alive.void
tryDestroy()
Try to kill the process.int
waitFor()
Wait, if necessary, until the process is terminated.boolean
waitFor(long timeout, java.util.concurrent.TimeUnit unit)
Wait, if necessary, until the process is terminated.-
Methods inherited from interface com.github.toolarium.system.command.IProcess
getErrorStream, getExitValue, getInputStream, getOutputStream, getPid, getProcessEnvironment, getStartTime, getSystemCommand, getTotalCpuDuration
-
-
-
-
Method Detail
-
waitFor
int waitFor() throws java.lang.InterruptedException
Wait, if necessary, until the process is terminated. This method returns immediately if the process has already terminated. If the process has not yet terminated, the calling thread will be blocked until the process exits.- Returns:
- the exit value, by convention, the value
0
indicates normal termination - Throws:
java.lang.InterruptedException
- if the current thread is interrupted by another thread while it is waiting, then the wait is ended and anInterruptedException
is thrown.
-
waitFor
boolean waitFor(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Wait, if necessary, until the process is terminated. This method returns immediately if the process has already terminated or the specified waiting time elapses.The default implementation of this methods polls the
exitValue
to check if the process has terminated. Concrete implementations of this class are strongly encouraged to override this method with a more efficient implementation.- Parameters:
timeout
- the maximum time to waitunit
- the time unit of thetimeout
argument- Returns:
- true if the process has exited; othweise false if the waiting time elapsed before the process has exited
- Throws:
java.lang.InterruptedException
- if the current thread is interrupted while waiting.
-
isAlive
boolean isAlive()
Check whether the process is alive.- Returns:
- true if it is alive; othweise false
-
tryDestroy
void tryDestroy()
Try to kill the process.
-
destroy
void destroy()
Destroy the process immediate. If the process is not alive, no action is taken.
-
getProcessHandle
java.lang.ProcessHandle getProcessHandle()
Get the process handle.- Returns:
- the process handle
-
-