我遇到了一个奇怪的Java问题ProcessBuilder.代码如下所示(略微简化)
public class Whatever implements Runnable
{
public void run(){
//someIdentifier is a randomly generated string
String in = someIdentifier + "input.txt";
String out = someIdentifier + "output.txt";
ProcessBuilder builder = new ProcessBuilder("./whateveer.sh", in, out);
try {
Process process = builder.start();
process.waitFor();
} catch (IOException e) {
log.error("Could not launch process. Command: " + builder.command(), e);
} catch (InterruptedException ex) {
log.error(ex);
}
}
}
Run Code Online (Sandbox Code Playgroud)
whatever.sh读取:
R --slave --args $1 $2 <whatever1.R >> r.log
Run Code Online (Sandbox Code Playgroud)
大量的实例Whatever被提交到ExecutorService …