multithreading - Is Java socket multi-thread safe? -


if have multiple java threads writing same socket instance simultaneously, affect integrity of objects read same socket? i.e., whether contents of objects messed etc. it's fine ordering of objects random.

in general, there no guarantees. bits of different objects end getting interleaved on wire, rendering result indecipherable. therefore, need provide external synchronization.

it interesting note single socket write @ os level not atomic. further discussion, see is safe issue blocking write() calls on same tcp socket multiple threads? , be careful sendmsg() family of functions.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -