Hi Edgar, had a quick look and I can spot no obvious issue (apart from starting batch files which is error prone). Having said that could you check out
* https://issues.apache.org/jira/browse/EXEC-57 <https://issues.apache.org/jira/browse/EXEC-57> * http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/issues/Exec57Test.java?view=markup <http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/issues/Exec57Test.java?view=markup> Thanks in advance, Siegfried Goeschl > On 03.12.2017, at 00:33, Edgar H <kaotix...@gmail.com> wrote: > > Hey guys, > > Recently I've been working with exec in order to execute several scripts > via Java. > > The thing is that I don't clearly understand how they work as I'm trying to > perform asycnhronous tasks and the process seems to keep on blocking > without continuing the execution, so what I did in the meantime is to > create manual Java Thread classes to perform all of them, which isn't > elegant at all. > > For example, I'm trying to run Icecast as a background process, and keep on > executing and instantiating more background ones, but it seems that with my > approach it keeps blocking. > > private void runIcecast() { > File file = new File("Icecast"); > for (File s : file.listFiles()) { > if (s.getName().equals("icecast.bat")) { > DaemonExecutor executor = new DaemonExecutor(); > executor.setWorkingDirectory(file); > executor.setExitValue(1); > CommandLine commandLine = new > CommandLine(s.getAbsolutePath()); > > try { > executor.execute(commandLine); > String line = "icecast -c icecast.xml"; > commandLine = CommandLine.parse(line); > executor.execute(commandLine, new > DefaultExecuteResultHandler()); > } catch (ExecuteException e) { > e.printStackTrace(); > } catch (IOException e) { > e.printStackTrace(); > } > } > } > } > > What should I do so a new Thread is created whenever the command is > executed? Or should I just create normal Thread classes as I've been doing > until now?