0

An open ObjectOutputStream sends a certain object initially, and the complementing ObjectInputStream successfully deserializes it. This OIS is then passed to the constructor of a separate thread class, which is required to continue read()ing further (updated) objects seamlessly. This part isn't happening. Is there something eluding me about the requirements when 'context switching' that stream going on here? Many thanks.

1 Answers1

1

The most important thing to do is to flush() the ObjectOutputStream before creating the ObjectInputStream, if you don't do this you can get into a deadlock.

Passing the ObjectInputStream to another thread won't cause a problem, in fact it avoids this issue if you read from different thread than you write to.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130