Java serialization and Objectstream is really a big hole.
Do not say the problem of multi-threaded environment, in a single thread, a socket can only maintain a objectoutputstream, the reason seems to be in the ObjectOutputStream lock mechanism or blocking things, otherwise it will lead to the receiver " Streamcorruptedexception:invalid Type Code AC ", the same as ObjectInputStream can only maintain one, otherwise the receiver will appear header error related exception.
It is said that the reason is that objectoutputstream at the time of construction, when the new one comes out, the output stream will be added to the beginning of a number of bytes to represent the beginning of the serialized object, multiple times new and not close will result in the flow there are multiple representations of the beginning of the place, the receiver will error.
Immediately feel Java io is really a big head, may be more than net and thread two mountain larger, and so on after the fate of the API to read the source, I will come back to fill it (flag
Java Pit Note: Objectiostream and iostream of various decorative device (first dig a hole, later to fill in detail)