If you have some kind of "main" thread, then you should perform I/O off of it. Have a thread dedicated to reading and to some extends processing the input. Either queue the results to the main thread if event based, on modify the model if using a shared state design.
See what ObjectInputStream.markSupported() returns. If it returns true, you can call ObjectInputStream.mark() at the beginning and then call ObjectInputStream.reset() to rewind the InputStream back to the place you marked so you can reuse it later.
BTW I don't want to read the same data twice, I just want to cancel the read so that I can send another request then read another response. – phunehehe Nov 25 '09 at 4:51 @phunehehe: If it returns false then mark/reset is not supported by this InputStream and this strategy won't work for you. Anyway, if you're not re-reading the same data twice (not mentioned in the original question) then the strategy wouldn't apply anyway.
Why don't you simply instantiate a new ObjectInputStream? Object instantiation is cheap these days. – Asaph Nov 25 '09 at 4:54 But the program blocks when I make another call to input = new ObjectInputStream(socket.getInputStream()); I think it must be a problem with the old stream (actually I think they are the same stream from the same socket).
Do I have to create another socket? – phunehehe Nov 25 '09 at 5:05 @phunehehe: Yeah. Open up a new socket.
– Asaph Nov 25 '09 at 5:13.
You can use a PushBackInputStream to accomplish this. After reading some bytes you can unread the bytes.
Thanks, please see my edit – phunehehe Nov 25 '09 at 5:07.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.