Class ExponentialTimeBackoff


  • public class ExponentialTimeBackoff
    extends Object
    Class provide support for exponential time backoff. This is convenient if you need to check some event periodically. The class provides next method that implements wait (blocking or non-blocking - returns true/false whether code can proceed).

    Class wait time grow exponentially up to maxBackoffMillis time: 1sec, 2 sec, 4 sec, 8 sec,...,maxBackoffMillis.

    • Method Detail

      • next

        public boolean next()
        Exponential backoff wait. If wait is blocking, Thread.sleep(long) is called and true is always returned. If wait is non-blocking, the method returns true if logic can proceed (enough time has elapsed)
        Returns:
        true if logic can proceed