[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Note on PushbackInputStream
From: |
Tom Tromey |
Subject: |
Re: Note on PushbackInputStream |
Date: |
20 Aug 2001 09:51:41 -0600 |
>>>>> "Dalibor" == Dalibor Topic <address@hidden> writes:
>> I can't see a way out of the situation either, without creating some
>> kind of dual block (block on *either* the pushback or the underlying
>> stream) or possibly setting a time interval to periodically come back
>> from the underlying stream and check the pushback.
Dalibor> I came up with the following pseudo-code:
Dalibor> [ ... ]
Dalibor> Thread A tries to read a single byte, and blocks. it keeps
Dalibor> acquiring and releasing the lock for the pushbackinputstream
Dalibor> while it blocks.
I think polling like your loop does is a bad idea. I would be very
reluctant to put code like that into the library.
I don't think this is actually a very important bug in practice. I'm
sure Sun's implementation has it too. I just thought it was
interesting from a design point of view.
Dalibor> If you've got this far, I'd like to hear comments :-) I think
Dalibor> that in a cooperative multi-threading environment the yield()
Dalibor> is necessary, since otherwise thread B might not be able to
Dalibor> get any CPU time to unread the byte, but I'm not sure.
Thread.yield() isn't guaranteed to do anything.
Tom
- Note on PushbackInputStream, Tom Tromey, 2001/08/06
- Re: Note on PushbackInputStream, Bryce McKinlay, 2001/08/10
- Re: Note on PushbackInputStream, John Keiser, 2001/08/18
- Re: Note on PushbackInputStream, Dalibor Topic, 2001/08/19
- Re: Note on PushbackInputStream,
Tom Tromey <=
- Re: Note on PushbackInputStream, Dalibor Topic, 2001/08/21
- Re: Note on PushbackInputStream, John Keiser, 2001/08/21
- Re: Note on PushbackInputStream, Stuart Ballard, 2001/08/21
- Re: Note on PushbackInputStream, John Keiser, 2001/08/21
- Re: Note on PushbackInputStream, Tom Tromey, 2001/08/21
- Re: Note on PushbackInputStream, Dalibor Topic, 2001/08/22