@Override
	public void run() {

		init();

		long start;
		long elapsed;
		long wait;

		// game loop
		while (running) {

			start = System.nanoTime();

			update();
			draw();
			drawToScreen();

			elapsed = System.nanoTime() - start;

			wait = targetTime - (elapsed / 1000000);
			if (wait < 0) {
				wait = 5;
			}

			try {
				Thread.sleep(wait);
			} catch (final Exception e) {
				e.printStackTrace();
			}
		}
	}