[android-developers] How to block a BufferedReader when no input is available?

2010-12-19 Thread DulcetTone
I have code in a worker thread that needs to efficiently read a constantly-growing input stream from a process. The issue is that the present design uses a sleep() for a short period if there is no input presently available, and I'd like the attempt to read the input stream simply *block* so it

Re: [android-developers] How to block a BufferedReader when no input is available?

2010-12-19 Thread Kostya Vasilyev
Use Java thread synchronization: http://www.javamex.com/tutorials/synchronization_wait_notify.shtml Have the reader thread wait when there is no data and the writer thread notify the reader when more data is available (and when it should exit its processing loop). -- Kostya 19.12.2010