Better alternative for PipedReader/PipedWriter?

后端 未结 4 1663
难免孤独
难免孤独 2021-02-09 00:01

I need to have a buffered char stream, into which I write in one thread and from which I read in another thread. Right now I\'m using PipedReader and PipedWriter fo

4条回答
  •  清歌不尽
    2021-02-09 00:54

    @Esko Luontola, I've been reading through your code in the sbt package to try to understand what you are doing. It seems like you want to start up a Process and pass input to it, and have the result of the action be teed to different places. Is this at all correct?

    I would try modifying the main loop in ReaderToWriterCopier so that instead of doing a read() - a blocking operation that apparently when a PipedReader is involved causes polling - you explicitly wait for the Writer to flush. The documentation is clear that flush causes any Readers to be notified.

    I'm not sure how to run your code so I can't get deeper into it. Hope this helps.

提交回复
热议问题