Hi all,
I have created a class to use singleton Socket to connect to an IP. I want that at a time, only a single
thread should be able to use this connection (use its InputStream and OutputStream).
Following is the code:
Further I will be using above class as follows:
Now my doubts are:
1. Is above code fine for multi threaded scenario
2. As Socket object is Static(and singleton), will it always return reference to same InputStream and OutputStream (implies they are also singleton).
If Yes than how to make InputStream and OutputStream thread safe.(one way is to use synchronized block in second code snippet)