title: Java mouse listener isn't working
body: <p>I'm studying Java and learning how to use mouse listener. However here is a very simple code which doesn't work.</p>
  
  <pre><code>import acm.program.*;
  import java.awt.event.*;
  
  public class Test extends GraphicsProgram{
  
      public void run() {
          isMouseClicked= false;
          addMouseListeners();
          while (true) {
              if (isMouseClicked) {
                  println ("OK");
                  break;
              }
          }
      }
  
      public void mouseClicked(MouseEvent e) {
          isMouseClicked= true;
      }
  
      private boolean isMouseClicked;
  
  }
  </code></pre>
  
  <p>The idea is very simple. "isMouseClicked" is false at the beginning, and once mouse is clicked, it turns to true and print "OK" in the screen. The problem I have is that, if I run in a normal mode, no matter how I click mouse, it will not hit and print "OK". However if I run it in the debug-mode. After I clicked mouse, put a breakpoint on</p>
  
  <pre><code>if (isMouseClicked);
  </code></pre>
  
  <p>Then it turns out that it is true and "OK" is printed. Can anyone tell me why is that? Many thanks in advance.</p>