quit = true; while (!animatorStopped) { try { Thread.sleep(1); } catch (InterruptedException e) { } }
  private void runExit() {    quit = true;    while (!animatorStopped) {      try {        Thread.sleep(1);      } catch (InterruptedException e) {      }    }    // Note: calling System.exit() synchronously inside the draw,    // reshape or init callbacks can lead to deadlocks on certain    // platforms (in particular, X11) because the JAWT's locking    // routines cause a global AWT lock to be grabbed. Instead run    // the exit routine in another thread.    new Thread(new Runnable() {        public void run() {          System.exit(0);        }      }).start();  }