public void run()
	{
		// Last tick time
		long lastTickTime = System.nanoTime();
		// How many time should the game tick each second.
		double nsPerTick = 1000000000 / TPS;
		// The number of unprocessed ticks.
		double unprocessedTicks = 0;
		// Updated visible TPS / FPS every second (see further down).
		long secondTimer = System.currentTimeMillis();
		
		// game tps
		int tps = 0;
		// game fps
		int fps = 0;

		while(running)
		{ 
			// Current tick time
			long currentTickTime = System.nanoTime();
			// Gets the number of ticks still required.
			unprocessedTicks += (currentTickTime - lastTickTime) / nsPerTick;
			// Ends this cycle and updates the last tick time.
			lastTickTime = currentTickTime;
			
			// If there is ticks to be done then do them before contineuing.
			while(unprocessedTicks >= 1)
			{
				if(displayManager.getActiveDisplay() != null)
					displayManager.getActiveDisplay().update();
				tps++;
				unprocessedTicks--;
			}
			
			try {
				sleep(2);
			} catch (InterruptedException e) {
				// Yields the system resources the thread is using if it fails.
				yield();
				Log.error(e);
			}

			// Increments the fps
			fps++;
			
			// If a second has passed 
			if(System.currentTimeMillis() - secondTimer > 1000)
			{
				secondTimer += 1000;
				curTPS = tps;
				curFPS = fps;
				tps = 0;
				fps = 0;
			}
			
		}
		// Closes game if the thread has been stopped.
		System.exit(0);
	}