/** * Causes the current thread to wait, if necessary, until the * process has 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. * * @exception InterruptedException if the current thread is * {@linkplain Thread#interrupt() interrupted} by another * thread while it is waiting, then the wait is ended and * an {@link InterruptedException} is thrown. */ public void waitFor() throws InterruptedException { while (!hasResult()) { Thread.sleep(SLEEP_TIME_MS); } }
/** * Causes the current thread to wait, if necessary, until the * process has 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. * * @param timeout the maximum time to wait in milliseconds * @exception InterruptedException if the current thread is * {@linkplain Thread#interrupt() interrupted} by another * thread while it is waiting, then the wait is ended and * an {@link InterruptedException} is thrown. */ public void waitFor(final long timeout) throws InterruptedException { final long until = System.currentTimeMillis() + timeout; while (!hasResult() && System.currentTimeMillis() < until) { Thread.sleep(SLEEP_TIME_MS); } } }
boolean isProcessAlive() { return processResultHandler != null && !processResultHandler.hasResult(); }
jobStatus.setStdErr(new String(stdErrStream.toByteArray())); if (resultHandler.hasResult()) { jobStatus.setState(JobStatus.State.COMPLETED);
return; if (processResultHandler.hasResult()) {
executor.execute(command, envVarsForApp, handler); startupWaiter.or(c -> handler.hasResult()); // stop waiting if the process exist startupWaiter.blockUntilReady(); if (handler.hasResult()) { String message = "The project at " + fullPath(projectRoot) + " started but exited all too soon. Check the console log for information."; buildLogHandler.consumeLine(message);