use of org.ow2.proactive.scheduler.task.utils.ThreadReader in project scheduling by ow2-proactive.
the class JavaSpawnExecutable method execute.
@Override
public Serializable execute(TaskResult... results) throws Throwable {
org.apache.log4j.Logger.getLogger(ProcessTree.class).setLevel(Level.DEBUG);
Process process = null;
process = Runtime.getRuntime().exec(getNativeExecLauncher(false), null, getExecutablePath(launchersDir).getParentFile().getCanonicalFile());
// redirect streams
BufferedReader sout = new BufferedReader(new InputStreamReader(process.getInputStream()));
BufferedReader serr = new BufferedReader(new InputStreamReader(process.getErrorStream()));
Thread tsout = new Thread(new ThreadReader(sout, System.out));
Thread tserr = new Thread(new ThreadReader(serr, System.err));
tsout.setDaemon(true);
tserr.setDaemon(true);
tsout.start();
tserr.start();
process.waitFor();
// we sleep 2 sec
Thread.sleep(sleep * 1000);
return true;
}
Aggregations