I want to be able to kick off an external process from within the JVM and reach on its completion.
I could use the ProcessBuilder to create a Process and then do Process.waitFor() to wait for its completion. However, this a blocking call and simply wastes thread resources.
It would make better sense to do this via an event handler and reactive programming. One would think that the JVM could register some sort of a listener with the OS to listen for process completion events, and relay that back to the program.
Does such a mechanism/ API exist? Any alternatives or libraries that achieve this?
Use the NuProcess library if you only need to support Windows, MacOS X, and Linux. It provides non-blocking access to external processes using a callback model -- including I/O and program termination. Disclosure: I am the author of said library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With