java - Correct Usage of ProcessBuilder -


After researching, I have found that to use Java processbilders, the "right" way to test the two other threads The stdout / stderr of the newly created process to make, so that it is not shown here:

but it left me thinking about 2 questions - 1.) Why is the basic process stdout rising and then gradually stderr?

2.) In addition, if you redirect the stream to go both to the studio, then it will be acceptable to swad stdout only to the original process, and then to worry about deadlocks Do not need to?

Keep your words in mind.

  1. Because the child can write both and when you have a buffer load for stderr (the child waits for the parent Stderr , waits for parents to close stdout .

  2. if not the child's process to stdin is also needed, you should handle stdin in your main thread and read the merged output stream through an extra thread and then It can be deadlock (child can wait) to read the output stream for parents and wait for the parent to read the data on stdin .


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -