@Override
    public void run() {
	running = true;
	long lastTime = System.nanoTime();
	double unprocessed = 0;
	double nsPerTick = 1000000000.0 / 60;
	int frames = 0;
	int ticks = 0;
	long lastTimer1 = System.currentTimeMillis();

	new Thread() {
	    public void run() {
		init();
	    }
	}.start();

	while (running) {
	    long now = System.nanoTime();
	    unprocessed += (now - lastTime) / nsPerTick;
	    lastTime = now;
	    boolean shouldRender = preferences != null && !preferences.video.vsync;
	    while (unprocessed >= 1) {
		ticks++;
		ticksRunning++;
		tick();
		unprocessed -= 1;
		shouldRender = true;
	    }

	    try {
		Thread.sleep(2);
	    } catch (InterruptedException e) {
		e.printStackTrace();
	    }

	    if (shouldRender) {
		frames++;
		render();
	    }

	    if (System.currentTimeMillis() - lastTimer1 > 1000) {
		lastTimer1 += 1000;
		if (DEBUG) {
		    if(translation != null) {
			frame.setTitle(translation.translate("game.title") + " - " + ticks + "TPS " + frames + "FPS");
			System.out.println(translation.translate("game.title") + " - " + ticks + "TPS " + frames + "FPS");
		    }
		}
		this.tps = ticks;
		this.fps = frames;
		frames = 0;
		ticks = 0;
	    }
	}
	cleanUp();
    }