Я пытаюсь запустить команду asyn c bash из файла java и дождаться ее завершения sh, прежде чем продолжить выполнение кода java.
В в этот момент я попытался использовать Callable
примерно так:
class AsyncBashCmds implements Callable{
@Override
public String call() throws Exception {
try {
String[] cmd = { "grep", "-ir", "<" , "."};
Runtime.getRuntime().exec(cmd);
return "true"; // need to hold this before the execution is completed.
} catch (Exception e) {
return "false";
}
}
}
, и я называю это так:
ExecutorService executorService = Executors.newFixedThreadPool(1);
Future<String> future = executorService.submit(new runCPPinShell(hookResponse));
String isFinishedRunningScript = future.get();
Спасибо !!!