public void tick ( ) throws InterruptedException { if ( mPreviousTickMs != 0 ) { long executionTimeMs = mClock . millis ( ) - mPreviousTickMs ; if ( executionTimeMs > mIntervalMs ) { mLogger . warn ( "{} last execution took {} ms. Longer than the interval {}" , mThreadName , executionTimeMs , mIntervalMs ) ; } else { mSleeper . sleep ( Duration . ofMillis ( mIntervalMs - executionTimeMs ) ) ; } } mPreviousTickMs = mClock . millis ( ) ; }
Enforces the thread waits for the given interval between consecutive ticks .