public void run(){
        long now = 0, prev = 0, dt = 0;

        // Bad game loop
        for(;;){

            for (Integer integer : toDelete) {
                for (System system : systems) {
                    system.removeEntity(integer);
                }
            }

            toDelete.clear();

            prev = java.lang.System.currentTimeMillis();

            for (System logicSystem : logicSystems) {
                logicSystem.update(dt);
            }

            for (System prerenderSystem : prerenderSystems) {
                prerenderSystem.update(dt);
            }

            for (System renderSystem : renderSystems) {
                renderSystem.update(dt);
            }

            for (System postRenderSystem : postRenderSystems) {
                postRenderSystem.update(dt);
            }

            now = java.lang.System.currentTimeMillis();

            java.lang.System.out.printf("Loop time: %d ms \r", java.lang.System.currentTimeMillis()- prev);

            // Fill remaining time
            try {
                if(frameTime - (now-prev) > 0)
                    Thread.sleep(frameTime - (now - prev));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            dt = now - prev;
        }
    }