/** * Waits the given amount of seconds. * <p> * If the given value is 0 or negative, the method returns immediately. If an <tt>InterruptedException</tt> * is thrown while waiting, the method will return immediately but ignore the exception. * * @param secondsToWait the number of seconds to wait */ public static void seconds(double secondsToWait) { millis((int) Math.round(1000 * secondsToWait)); }
/** * Waits for an random amount of millisecond within the given bounds. * <p> * Note that minWaitMillis may be negative. This can be used to only block the thread in a given percentage of * all calls. So if the thread should wait between 0 and 500ms in 50% of all calls * {@code randomMillis(-500, 500)} can be invoked. Using this bounds, the expected wait time will be * between -500ms and 0ms in 50% of all calls (on average). As negative delays are ignored, the method * will return immediately. * * @param minWaitMillis the minimal time to wait in millis. * @param maxWaitMillis the maximal time to wait in millis. This must be >= minWaitMillis and also > 0 or the * method will always return immediately */ public static void randomMillis(int minWaitMillis, int maxWaitMillis) { if (minWaitMillis > maxWaitMillis || maxWaitMillis < 0) { return; } int pauseInMillis = minWaitMillis + rnd.nextInt(maxWaitMillis - minWaitMillis); millis(pauseInMillis); }
Wait.millis(waitInMillis); waitInMillis = Math.min(1500, waitInMillis + 500); } while (System.currentTimeMillis() < timeout);
Wait.millis((2 - retries) * 500);