private void run()
			{
				int frames = 0;

				double unprocessedSeconds = 0;
				long lastTime = System.nanoTime();
				double secondsPerTick = 1 / 60.0;
				int tickCount = 0;

				while (true)
					{
						if (focused)
							{
								long now = System.nanoTime();
								long passedTime = now - lastTime;
								lastTime = now;
								if (passedTime < 0)
									passedTime = 0;
								if (passedTime > 100000000)
									passedTime = 0;

								unprocessedSeconds += passedTime / 1000000000.0;

								boolean ticked = false;
								while (unprocessedSeconds > secondsPerTick)
									{
										tick();
										ticked = true;
										tickCount++;

										unprocessedSeconds -= secondsPerTick;

										if (tickCount % 60 == 0)
											{
												lastFrames = frames;
												frames = 0;
											}
									}

								if (ticked)
									{
										render();
										frames++;
									}
							}
						else
							render();
						try
							{
								Thread.sleep(focused ? 1 : 100);
							}
						catch (InterruptedException e)
							{
								Tools.errorWindow(e, "MAIN LOOP");
							}
					}
			}