public void run()
	{
        long lastTime = System.nanoTime();
        double nsPerTick = 1000000000D / 60D;
        lastTimer = System.currentTimeMillis();
        double i1 = 0;

        while (running == true) 
        {
            long now = System.nanoTime();
            i1 += (now - lastTime) / nsPerTick;
            lastTime = now;
            boolean shouldRender = true;

            while (i1 >= 1) {
                tick();
                i1 -= 1;
                shouldRender = true;
            }
            
            try { Thread.sleep(2); } 
            catch (InterruptedException e) {
            }

            if (shouldRender == true) {
                render();
            }

            if (System.currentTimeMillis() - lastTimer >= 1000) {
                lastTimer += 1000;                
            }
        
        }
    }