public class Java8Process extends JavaProcess
Process since Java 8.
Java 8 added following methods:
isAlive()destroyForcibly()waitFor(long, TimeUnit)process| Constructor and Description |
|---|
Java8Process(Process process) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canDestroy(boolean forceful)
Check if destroying the process is supported based on the OS and JVM version (regardless the process is running or not).
|
protected void |
invokeDestroy(boolean forceful) |
Process |
invokeDestroyForcibly() |
boolean |
isAlive()
Tests whether this process is alive.
|
static boolean |
isSupported() |
boolean |
waitFor(long timeout,
TimeUnit unit)
Causes the current thread to wait, if necessary, until the process handled by this killer has terminated, or the specified timeout is reached.
|
destroy, getDescription, getProcess, waitFordestroyForcefully, destroyGracefully, toStringpublic Java8Process(Process process)
public static boolean isSupported()
protected boolean canDestroy(boolean forceful)
JavaProcesscanDestroy in class JavaProcessforceful - true if the process must be destroyed forcefully (like kill -KILL),
false if it must be destroyed gracefully (like kill -TERM).true if JavaProcess.invokeDestroy(boolean) is supported with the given forceful flag on the given system.protected void invokeDestroy(boolean forceful)
invokeDestroy in class JavaProcesspublic Process invokeDestroyForcibly()
public boolean isAlive()
SystemProcessThis operation may take some time to finish.
isAlive in interface SystemProcessisAlive in class JavaProcesstrue if this process is alive, false if it is finished or not found.public boolean waitFor(long timeout,
TimeUnit unit)
throws InterruptedException
AbstractProcess
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.
waitFor in interface SystemProcesswaitFor in class AbstractProcesstimeout - the maximum time to waitunit - the time unit of the timeout argumenttrue if the process has exited and false if the timeout is reached before the process has exited.InterruptedException - if interrupted.Copyright © 2019 ZeroTurnaround. All rights reserved.