@Override
	public void run() {
		// These variables should sum up to 17 on every iteration
		long updateDurationMillis = 0; // Measures both update AND render
		long sleepDurationMillis = 0; // Measures sleep
		while (running) {
			long beforeUpdateRender = System.nanoTime();
			long deltaMillis = updateDurationMillis + sleepDurationMillis;

			updateAndRender(deltaMillis);

			updateDurationMillis = (System.nanoTime() - beforeUpdateRender) / 1000000L;
			sleepDurationMillis = Math.max(2, 17 - updateDurationMillis);

			try {
				Thread.sleep(sleepDurationMillis);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		// End game immediately when running becomes false.
		System.exit(0);
	}