Thread-launched running processes won't destroy (Java)

前端 未结 8 822
清歌不尽
清歌不尽 2021-02-01 08:41

Starting multiple threads and having each exec() then destroy() a running java process result in some of the process not being destroyed and still running after program exit. He

8条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-01 09:30

    If subprocesses write anything to stdout or stderr (intentionally or not), that could cause trouble:

    "Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock."

    Source: http://www.javaworld.com/jw-12-2000/jw-1229-traps.html

    The whole article is IMO worth reading if you need to use Runtime.exec().

提交回复
热议问题