"is java socket multi-thread safe?" Code Answer

2

in general, there are no guarantees. bits of different objects could well end up getting interleaved on the wire, rendering the result indecipherable. therefore, you need to provide external synchronization.

it is interesting to note that even a single socket write at the os level is not necessarily atomic. for further discussion, see is it safe to issue blocking write() calls on the same tcp socket from multiple threads? and be careful with the sendmsg() family of functions.

By iamsult on August 22 2022

Answers related to “is java socket multi-thread safe?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.