title: Multi-threaded Java TCP Client
body: <p>I am writing a Java client application(Basic Java Net package with TCP/IP). The client must take input from the system.in and at the same time must listen to any messages coming from server through socket inputstream. 
  Once an input from the system.in is received, the client will get that input, do some processing and send it to the server as a request.
  So basically 2 processes run, </p>
  
  <p>-listening to client request</p>
  
  <p>-listning to server responses. </p>
  
  <p>I implemented 2 threads for this and ran the processing of messages in the main thread.
  Is this good enough design.?</p>
  
  <p>And is there a way to return the message received from the system.in to the main thread. The threads run() method returns void. I used a volatile variable to return the string received but its said that volatile is very costly since it doesn't use cpu cache to store the variable.</p>