commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edgar H <>
Subject [exec] Misunderstanding DaemonExecutor and DefaultExecutor for asynchronous execution
Date Sat, 02 Dec 2017 23:33:32 GMT
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();
                CommandLine commandLine = new

                try {
                    String line = "icecast -c icecast.xml";
                    commandLine = CommandLine.parse(line);
                    executor.execute(commandLine, new
                } catch (ExecuteException e) {
                } catch (IOException e) {

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?

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message