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(); } } }
public synchronized void setSize(int width, int height) { if (this.width == width && this.height == height) { return; } else { frontbufferValid = false; state = 0; backbuffer = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR); frontbuffer = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR); this.width = width; this.height = height; screen.setSize(width, height); this.notifyAll(); } }