public void start() {
        try {
            preStartup();
            running = true;
            long lr = System.currentTimeMillis();
            long lu = lr;
            while (isRunning()) {
                boolean updated = false;
                if (shouldUpdate(lu)) {
                    int d = (int) (System.currentTimeMillis() - lu);
                    lu = System.currentTimeMillis();
                    update(d);
                    updated = true;
                }
                if ((updated && renderAfterUpdate) || shouldRender(lr)) {
                    int d = (int) (System.currentTimeMillis() - lr);
                    lr = System.currentTimeMillis();
                    render(d);
                }
                window.update();
            }
        } catch (Exception e) {
            handleError(e);
        } finally {
            shutdown();
        }
    }