(Of course, what you need is a loop of !ready ->sleep(nnn)) On Dec 19, 8:09 am, DanH <[email protected]> wrote: > ready? > > On Dec 19, 7:38 am, DulcetTone <[email protected]> wrote: > > > 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 magically awakes when more > > input is available. I fear this will mean a small hit on phone > > responsiveness. > > > How does one alter code from this form to do such a thing? > > > BufferedReader bufferedReader = > > new BufferedReader(new > > InputStreamReader(process.getInputStream())); > > > do { > > String line; > > while ((line = bufferedReader.readLine()) != null) { > > // new input would be processed here > > } > > Thread.sleep(500); // TODO: make this go away > > } while (true);
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

