Is sockets and input/output-streams thread-safe?
843790Mar 8 2007 — edited Mar 9 2007Hi
When creating a simple socket client application I would usually use BufferedReader on the inputstream, PrintWriter on the outputstream and a regular socket as the foundation running within its own thread and responding to events from the Swing UI. Now the question is:
Is for instance the Socket.close() and PrintWriter.write() methods thread safe? Will it lead to problems if these are called from other or perhaps even several other threads? If so, how can I fix this?
I have been googling for this for a while without any significant results, and no tutorials/examples of this scenario has done anything to protect against potential thread issues.