private void gameThread() {
		running = true;
		try {
			long beginTime = System.nanoTime();
			double previousDelta = 0.0;
			boolean runningSlowly = false;
			
			while(running) {
				if(interval <= 0) throw new Error("GameTimer interval must be >= 0.");
				
				long frameStartTime = System.nanoTime();
				double givenDelta = capDelta ?
						Math.min(previousDelta, interval) :
						previousDelta; // works out the (maybe) capped delta
						
				tickHandler.tick(
						givenDelta,
						(double)(frameStartTime - beginTime) / 1e+9,
						runningSlowly);
				
				long frameDeltaTime = System.nanoTime() - frameStartTime;
				double runningTime = (double)(frameDeltaTime) / 1e+9;
				
				long sleepTime = (long)(interval * 1e+9) - frameDeltaTime;
				runningSlowly = sleepTime < 0;
				if(runningTime < interval) {
					if(sleepTime >= 100000) {
						// only sleep if sleepTime's not too small
						Thread.sleep(
								sleepTime / 1000000l,
								(int)(sleepTime % 1000000l));
					}
				}
				previousDelta = (double)
						(System.nanoTime() - frameStartTime) / 1e+9;
			}
		} catch(InterruptedException e) {
			// ok
		} catch(Exception e) {
			errorHandler.handle(e);
		} finally {
			cleanupHandler.cleanup();
		}
	}