title: Strange java behavior with while loop and queue
body: <p>I have strange behavior of while(true) loop. Here is the code:</p>
  
  <p>As a member of class I have:</p>
  
  <pre><code>static Queue&lt;Object&gt; response = new LinkedList&lt;Object&gt;();
  </code></pre>
  
  <p>... and a function:</p>
  
  <pre><code>private void read() {
  
      while (true)
      {
          System.out.println("foo");
          if(!(response.isEmpty()))
          {
  
              if((Boolean)response.peek() == true)
              {
                  view.dispose();
                  LogInControler controler= new LogInControler();
                  disableMasterLogin();
                  response.poll();
                  return;
              }
              else if((Boolean)response.poll() == false)
              {
                  JOptionPane.showMessageDialog(view.getRootPane(), 
                          "Wrong username or password.");
                  view.tfUsername.requestFocus();
                  return;
              }
          }
      }
  }
  </code></pre>
  
  <p>When object is received from server(via Socket), InputController class pass that object to appropriate controller, in this case MasterLogInController and put it in Queue response.
  I am waiting for that response in while(true) loop, but the problem is if I remove "System.out.printline("foo");" loop will be entered only once!? With this syso line I "force" while loop to do loops until response is received. What's wrong here?</p>