public void sleep(final long startTime) {
        if (this.stopper.isStopped()) {
            return;
        }
        long now = System.currentTimeMillis();
        long waitTime = this.period - (now - startTime);
        if (waitTime > this.period) {
            logger.warn("Calculated wait time > " + this.period + "; setting to this.period: "
                    + System.currentTimeMillis() + ", " + startTime);
            waitTime = this.period;
        }
        while (waitTime > 0) {
            long woke = -1;
            try {
                if (triggerWake.get()) {
                    break;
                }
                synchronized (sleepLock) {
                    sleepLock.wait(waitTime);
                }
                woke = System.currentTimeMillis();
                long slept = woke - now;
                if (slept - this.period > MINIMAL_DELTA_FOR_LOGGING) {
                    logger.warn("We slept " + slept + "ms instead of " + this.period
                            + "ms, this is likely due to a long "
                            + "garbage collecting pause and it's usually bad!");
                }
            } catch (InterruptedException iex) {
                // We we interrupted because we're meant to close? If not, just
                // continue ignoring the interruption
                if (this.stopper.isStopped()) {
                    return;
                }
            }
            // Recalculate waitTime.
            woke = (woke == -1) ? System.currentTimeMillis() : woke;
            waitTime = this.period - (woke - startTime);
        }
        triggerWake.compareAndSet(true, false);
    }
Sleep for period adjusted by passed startTime

@param startTime Time some task started previous to now.
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/common/utils/Sleeper.java