|
From: | Bryce McKinlay |
Subject: | Re: Note on PushbackInputStream |
Date: | Fri, 10 Aug 2001 17:25:58 +1200 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.3) Gecko/20010801 |
Tom Tromey wrote:
In general, I dont think its useful/safe to have more than one thread reading from any given InputStream, so in practise this probibly isnt a problem. Besides, even if there was a way to unblock another reading thread, there would still be consistency issues. If thread A reads a chunk of data, then thread B reads a chunk, then thread A decides to push back a byte, that byte would no longer be in the correct position on the stream.Suppose a thread calls PushbackInputStream.read and there are no bytes to be read. So the thread blocks. Now suppose another thread calls PushbackInputStream.unread. Ideally you'd expect the first thread to wake up and read the pushed-back bytes. However, this doesn't happen. And in fact it isn't easy to make it happen. I think you could do it by making a new thread inside PushbackInputStream.read. That is awfully heavy though.
regards Bryce
[Prev in Thread] | Current Thread | [Next in Thread] |