public void run() {
        super.run();
        running = true;
        while (running) {
            beginTime = System.currentTimeMillis();
            this.update(timeDiff);

            do {
                do {
                    this.draw();
                } while (strategy.contentsRestored());
                strategy.show();
            } while (strategy.contentsLost());

            timeDiff = System.currentTimeMillis() - beginTime;
            if (timeDiff == 0) timeDiff++;
            sleepTime = (int) (FRAME_PERIOD - timeDiff);

            if (sleepTime > 0) {
                try {
                    sleep(sleepTime);
                } catch (InterruptedException e) {
                }
            }
            while (sleepTime < 0 && framesSkipped < MAX_FRAME_SKIPS) {
                update(timeDiff);
                sleepTime += FRAME_PERIOD;
                framesSkipped++;
            }
        }
    }