Interface IAsynchronousProcess

    • 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 an InterruptedException 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 wait
        unit - the time unit of the timeout 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