in what way is java.net.Socket threadsafe?

前端 未结 6 692
挽巷
挽巷 2020-12-10 05:11

I have a Socket that I am both reading and writing to, via BufferedReaders and BufferedWriters. I\'m not sure which operations are okay to do from separate threads. I would

6条回答
  •  猫巷女王i
    2020-12-10 06:07

    You actually read from InputStream and write to OutputStream. They are fairly independent and for as long as you serialize access to each of them you are ok.

    You have to correlate, however, the data that you send with data that you receive. That's different from thread safety.

提交回复
热议问题