Details on the use of Java object streams note
Recent programming uses some things to stream objects, so put the use experience and the lessons in it to the public
1. Blocking problems when object stream is created
When using TCP communication, object flow is relatively convenient, but it is worth noting that the object stream is created in a certain order, otherwise it will always block.
There are two things that must be one by one to correspond.
(1) The service side first establishes the ObjectInputStream and then establishes the ObjectOutputStream
The client first establishes the ObjectOutputStream and then establishes the Objectinoutstream
(2) The service side first establishes the ObjectOutputStream and then establishes the Objectinoutstream
The client first establishes the ObjectInputStream and then establishes the ObjectOutputStream
2. The object stream input must be flush or the other side may not receive