2014-09-18 227 views
0

有没有办法告诉Apache DefaultExecutor不要等待结果并继续执行代码?目前,它等待被调用的程序或脚本终止。DefaultExecutor不等待结果(异步调用)

+1

使用异步调用:http://commons.apache.org/proper/commons-exec/apidocs/org/apache/commons/exec/DefaultExecutor.html#execute (org.apache.commons.exec.CommandLine, java.util.Map,org.apache.commons.exec.ExecuteResultHandler) – Fildor 2014-09-18 20:11:00

回答

1

DefaultExecutor具有用于异步执行的方法。

without environment

public void execute(CommandLine command, ExecuteResultHandler handler) 
               throws ExecuteException, IOException 

with environment argument

public void execute(CommandLine command, Map<String,String> environment, ExecuteResultHandler handler) 
     throws ExecuteException, IOException 

如果你想忽略的结果,你可以通过ExecuteResultHandler的无操作实现。