@Override
    public void endWindow() {
      long sleepMillis =
          latency
              - (System.currentTimeMillis()
                  - WindowGenerator.getWindowMillis(
                      currentWindowId, firstWindowMillis, windowWidthMillis));

      if (sleepMillis > 0) {
        try {
          Thread.sleep(sleepMillis);
        } catch (InterruptedException ex) {
          // move on
        }
      }
    }