Blocking vs. Non-Blocking Calls

suggest change

In general when making a call to the command line, the program will send the command and then continue its execution.

However you may want to wait for the called program to finish before continuing your own execution (ex. The called program will write data to a file and your program needs that to access that data.)

This can easily be done by calling the waitFor() method from the returned Process instance.

Usage example:

//code setting up the commands omitted for brevity...

ProcessBuilder pb = new ProcessBuilder(cmds);

try {
    Process p = pb.start();
} catch (IOException e) {
} catch (InterruptedException e) {

//more lines of code here...

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents