@Override
    public void run() {
        long lastTime = System.nanoTime();
        long unprocessedTime = 0;
        try {
            Thread.sleep(500);
        } catch (InterruptedException e1) {
            e1.printStackTrace();
        }


        while (true) {
            long now = System.nanoTime();
            unprocessedTime += now - lastTime;
            lastTime = now;

            int max = 10;
            if (!pause) {
                while (unprocessedTime > 0) {
                    unprocessedTime -= 1000000000 / 60;
                    // Contador de iteraciones
                    i++;

                    if (i >= 400 && i % 80 == 0) {
                        if (i >= 1000) {
                            SingletonGame.getInstance().addChicken(i / 1000);
                        }
                        else {
                            SingletonGame.getInstance().addChicken(1);
                        }
                    }
                    SingletonGame.getInstance().step();

                    if (max-- == 0) {
                        unprocessedTime = 0;
                        break;
                    }
                }
        }

            repaint();

            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {;
            }
        }
    }