DefaultExecutor不等待结果

DefaultExecutor不等待结果

本文介绍了DefaultExecutor不等待结果(异步调用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以告诉Apache DefaultExecutor不要等待结果并继续执行代码?当前,它等待被调用的程序或脚本终止.

Is there a way to tell Apache DefaultExecutor not to wait for result and go on with code? Currently, it waits for a called program or script to terminate.

推荐答案

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

The DefaultExecutor has methods for asynchronous execution.

没有环境:

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

带有环境参数

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

如果要忽略结果,可以传递ExecuteResultHandler的无操作实现.

If you want to ignore the results, you can pass a no-op implementation of the ExecuteResultHandler.

这篇关于DefaultExecutor不等待结果(异步调用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 07:39