Class ProcessRunner

  • All Implemented Interfaces:
    AutoCloseable

    public class ProcessRunner
    extends Object
    implements AutoCloseable
    Shelling out to a process is harder than it ought to be in Java. If you don't read stdout and stderr on their own threads, you risk deadlock on a clogged buffer. ProcessRunner allocates two threads specifically for the purpose of flushing stdout and stderr to buffers. These threads will remain alive until the ProcessRunner is closed, so it is especially useful for repeated calls to an external process.