I made an app that use 6 process. There is no option for me to reduce this number.
I used to start those processed from java with some module I build around:
Runtime.getRuntime().exec() But it created a lot of troubles with errors handling. Terminating a process is not trivial.
So I moved to command line, and I wrote a batch script to start 6 command prompt(Windows consul window), now closing those also kill the process, so error handling become easier.
But it look very bad... Messy...
I guess this is not a common way to work, so my question is what is? How to manage multiple java processes with the next behaviors:
- Process can crash
- Optionally there is a dependency between processes, so if process A is terminated/crash, process B should be terminated as well, it's optional as it's easier for me to manage it this way, but I can code around it, so it's not mandatory.
- Process can be force stopped with some timeout if it fails to complete it's task.
Process.destroy()? What OS are you running this on?Process.destroy(). It's not relevant in any case, the relevance to your question is: what problems do you have withProcess.destroy()if any. Show that in your question.