Example usage for java.lang Process wait

List of usage examples for java.lang Process wait

Introduction

In this page you can find the example usage for java.lang Process wait.

Prototype

public final void wait() throws InterruptedException 

Source Link

Document

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Usage

From source file:com.ebay.logstorm.server.platform.spark.SparkExecutionPlatform.java

@Override
public synchronized void stop(final PipelineExecutionEntity entity) throws Exception {
    String applicationId = entity.getProperties().getProperty("applicationId");
    String driverPid = entity.getProperties().getProperty("driverPid");
    String cmd = "kill -9 " + driverPid;
    Process process = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", cmd });
    synchronized (process) {
        try {/*from  w w w.  java2  s  . co  m*/
            process.wait();
        } catch (Exception e) {
            LOG.warn("failed to kill the application {}, driver pid {}", applicationId, driverPid, e);
            return;
        }
    }
    LOG.info("kill the application {}, driver pid {}", applicationId, driverPid);
    entity.setStatus(PipelineExecutionStatus.STOPPED);
}

From source file:org.scantegrity.scanner.ScannerController.java

/**
 * Kill a process based on the PID./*  w  ww  .  j  av  a  2s  .  co  m*/
 * 
 * @param p_pid
 */
private void killPid(int p_pid) {
    Process l_process = null;

    try {
        synchronized (this) {
            l_process = Runtime.getRuntime().exec(String.format(c_killcmd, p_pid));
            l_process.wait();
        }
    } catch (Exception l_e) {
        //Nothing.
    } finally {
        closeProcess(l_process);
    }
}