base/common/src/main/com/thesett/common/throttle/BaseThrottle.java
public void throttle() throws InterruptedException
    {
        // Don't introduce any pause on the first call.
        if (!firstCall)
        {
            // Check if there is any time left in the cycle since the last throttle call to this method and introduce a
            // short pause to fill that time if there is.
            long remainingTimeNanos = timeToThrottleNanos();

            while (remainingTimeNanos > 0)
            {
                long milliPause = remainingTimeNanos / 1000000;
                int nanoPause = (int) (remainingTimeNanos % 1000000);

                Thread.sleep(milliPause, nanoPause);

                remainingTimeNanos = timeToThrottleNanos();
            }
        }
        else
        {
            firstCall = false;
        }
    }
public void throttle() throws InterruptedException
    {
        // Don't introduce any pause on the first call.
        if (!firstCall)
        {
            // Check if there is any time left in the cycle since the last throttle call to this method and introduce a
            // short pause to fill that time if there is.
            long remainingTimeNanos = timeToThrottleNanos();

            while (remainingTimeNanos > 0)
            {
                long milliPause = remainingTimeNanos / 1000000;
                int nanoPause = (int) (remainingTimeNanos % 1000000);

                Thread.sleep(milliPause, nanoPause);

                remainingTimeNanos = timeToThrottleNanos();
            }
        }
        else
        {
            firstCall = false;
        }
    }
public void throttle ( ) throws InterruptedException { // Don't introduce any pause on the first call. if ( ! firstCall ) { // Check if there is any time left in the cycle since the last throttle call to this method and introduce a // short pause to fill that time if there is. long remainingTimeNanos = timeToThrottleNanos ( ) ; while ( remainingTimeNanos > 0 ) { long milliPause = remainingTimeNanos / 1000000 ; int nanoPause = ( int ) ( remainingTimeNanos % 1000000 ) ; Thread . sleep ( milliPause , nanoPause ) ; remainingTimeNanos = timeToThrottleNanos ( ) ; } } else { firstCall = false ; } }
This method can only be called at the rate set by the {@link #setRate} method, if it is called faster than this
it will inject short pauses to restrict the call rate to that rate.

@throws InterruptedException If interrupted whilst performing a blocking wait on the throttle.
This method can only be called at the rate set by the { @link #setRate } method if it is called faster than this it will inject short pauses to restrict the call rate to that rate .