Sunday, February 9, 2014

Multithreading issues of shared socket


            
I have three threads share a single socket.
Thread 1: socket for receiving input, socket.readLine ();
Thread 2: used to send heartbeat messages, and determine whether the correct response, and then sleep 10s. Repeat
Thread 3: used when the heartbeat is detected after disconnecting and re-connecting socket: new Socket ();
The question is how are sending thread 2 not out, I do not know why.
The reason is not synchronized back to the thread caused it?

No comments:

Post a Comment