org.zeroturnaround.process
Class Java8Process
java.lang.Object
org.zeroturnaround.process.AbstractProcess
org.zeroturnaround.process.JavaProcess
org.zeroturnaround.process.Java8Process
- All Implemented Interfaces:
- SystemProcess
public class Java8Process
- extends JavaProcess
Wrapper for Process since Java 8.
Java 8 added following methods:
isAlive()
destroyForcibly()
waitFor(long, TimeUnit)
Java8Process
public Java8Process(Process process)
isSupported
public static boolean isSupported()
canDestroy
protected boolean canDestroy(boolean forceful)
- Overrides:
canDestroy in class JavaProcess
- Returns:
true if JavaProcess.invokeDestroy(boolean) is supported with the given forceful flag on the given system.
invokeDestroy
protected void invokeDestroy(boolean forceful)
- Overrides:
invokeDestroy in class JavaProcess
invokeDestroyForcibly
public Process invokeDestroyForcibly()
isAlive
public boolean isAlive()
- Description copied from interface:
SystemProcess
- Tests whether this process is alive.
This operation may also take some time to finish.
- Specified by:
isAlive in interface SystemProcess- Overrides:
isAlive in class JavaProcess
- Returns:
true if this process is alive, false if it is finished or not found.
waitFor
public boolean waitFor(long timeout,
TimeUnit unit)
throws InterruptedException
- Description copied from class:
AbstractProcess
- Causes the current thread to wait, if necessary, until the process handled by this killer has terminated, or the specified waiting time elapses.
If the process has already terminated then this method returns immediately with the value true.
If the process has not terminated and the timeout value is less than, or equal to, zero, then this method returns immediately with the value false.
- Specified by:
waitFor in interface SystemProcess- Overrides:
waitFor in class AbstractProcess
- Parameters:
timeout - the maximum time to waitunit - the time unit of the timeout argument
- Returns:
true if the process has exited and false if the waiting time elapsed before the process has exited.
- Throws:
InterruptedException
Copyright © 2015 ZeroTurnaround. All rights reserved.