title: Java server response to a specific time(timeout)
body: <p>I'm make simple game(with server) in java.
  I would like to receive packets from the server to a certain time, but do not know how to solve it.</p>
  
  <p>What is an effective solution?</p>
  
  <p>For example in pseudo:</p>
  
  <pre><code>Thread one:
      tryToGetPacketFromServer(){
            GETPACKET...
      }
  Thread two:
      timer(){
       if gettin time of thread one &gt; 5 second;
       print errorr and stop thread one..
      }
  </code></pre>