java - Better alternative for PipedReader/PipedWriter? -


I should have a buffer char , in which I write in a thread and from which I read in another thread I am using it and for this, there is a display problem in those classes: PipedReader is a wait (1000) when its internal buffer is empty , Which seems to show my application.

Should there be a library that works like a yellow reader / piped viter, but with better performance? Or do I have to implement my own wheels?

There is some data for. When any pder reader reads and the buffer is empty, then the pypdroid loop will stop using a wait (1000) call until the buffer has some data.

Solution call PipedWriter.flush () always after writing some pipe Whichever flush do all call notify all () on the reader Correct the code in question.

(For me the piped reader / pipudwetter implementation looks like a case of adaptation long ago - why not notify everyone to write? Besides, wait readers in an active loop, every other Instead of waking instead of waking, only when something is read. The code also contains some flare remarks, so that the reader / writer thread can be detected which is not enough.)

This is the same Even Or even appears in my current project flush () is not manually possible (Commons IO can not be modified), so I made it to the pipe classes. They work a lot better than the basic classes. : -)


Comments