I am trying to find an answer to the following weird condition.
I have written Dispatcher class that accepts client requests and forwards them to appropriate server instances. There are 3 server instances.
The code is some what as follows
However the program just hangs while trying to do s.getInputStream() above. The server is running and exeuctes fine.
Why does the program block at
[ April 22, 2005: Message edited by: Naveen Sampra ]
The ObjectInputStream constructor blocks until it completes reading the serialization stream header. Code which waits for an ObjectInputStream to be constructed before creating the corresponding ObjectOutputStream for that stream will deadlock, since the ObjectInputStream constructor will block until a header is written to the stream, and the header will not be written to the stream until the ObjectOutputStream constructor executes. This problem can be resolved by creating the ObjectOutputStream before the ObjectInputStream, or otherwise removing the timing dependency between completion of ObjectInputStream construction and the creation of the ObjectOutputStream.
Java Object Serialization Specification