code: public void sync() {
          if (nextTick < 0) {
              throw new IllegalStateException("Timer was not started");
          }
          if (tps <= 0) {
              return;
          }
          try {
              // Sleep until the average sleep time is greater than the time remaining until next tick
              for (long time1 = getTime(), time2; nextTick - time1 > sleepDurations.average(); time1 = time2) {
                  Thread.sleep(1);
                  // Update average sleep time
                  sleepDurations.add((time2 = getTime()) - time1);
              }
              // Slowly dampen sleep average if too high to avoid yielding too much
              sleepDurations.dampen();
              // Yield until the average yield time is greater than the time remaining until next tick
              for (long time1 = getTime(), time2; nextTick - time1 > yieldDurations.average(); time1 = time2) {
                  Thread.yield();
                  // Update average yield time
                  yieldDurations.add((time2 = getTime()) - time1);
              }
          } catch (InterruptedException ignored) {
          }
          // Schedule next frame, drop frames if it's too late for next frame
          nextTick = Math.max(nextTick + 1000000000 / tps, getTime());
      }
docs: An accurate sync method that will attempt to run at the tps. It should be called once every tick.