title: Thread stuck in readUTF()
body: <p>I have the following class:</p>
  
  <pre><code>public class Prices {
  
      String priceValues;
  
      public String getPriceValues() {
          return priceValues;
      }
  
      public void setPriceValues(String priceValues) {
          this.priceValues = priceValues;
      } 
  }
  </code></pre>
  
  <p>This is my <code>run</code> method in the <code>SocketServer</code> class:</p>
  
  <pre><code>public void run() {
        while(true) {
           try {
              DataInputStream in = new DataInputStream(server.getInputStream());
  
              System.out.println(in.readUTF());
              prices.setPriceValues(in.readUTF());
              DataOutputStream out = new DataOutputStream(server.getOutputStream());
              out.writeUTF("Thank you for connecting to " + server.getLocalSocketAddress()
                 + "\nGoodbye!");
              //server.close();
  
           }catch(SocketTimeoutException s) {
              System.out.println("Socket timed out!");
              break;
           }catch(IOException e) {
              e.printStackTrace();
              break;
           }
        }
     }
  </code></pre>
  
  <p>Everything runs fine but I want to store what I am receiving from the client in such a way in which it can be accessed by any class. So I created a class called <code>Prices</code>. </p>
  
  <p>However, the thread gets stuck on the following line:</p>
  
  <pre><code>prices.setPriceValues(in.readUTF());
  </code></pre>
  
  <p>The <code>prices</code> variable is not null, and everything runs fine when I take this line out. </p>