Example #1
0
  public void run() {

    while (true) {
      int event = getEvent();

      if (event == 2) return;
      // Thread should stop

      if (event == 0) {
        screen.drawToComponent(backbuffer.getGraphics());

        synchronized (this) {
          Image temp = frontbuffer;
          frontbuffer = backbuffer;
          backbuffer = temp;
          frontbufferValid = true;
          state = 1;
          this.notifyAll();
        }
      } else if (event == 3) {
        DasherTasklet toRun = events.remove();
        toRun.run();
      }
    }
  }