Code example for Stopwatch

Methods: sleep

0
            130, 60, 140, 150, 90, 35, 230, 180, 200, 165, 170, 75, 280, 150, 260, 105}; 
 
    public static void performIOOperation(float seconds) throws InterruptedException {
        long milliseconds = (long) (1000 * seconds);
 
        Stopwatch watch = new Stopwatch().start();
 
        int timeoutCount = sleepTimeouts.length;
 
        int i = (Math.abs(watch.hashCode())) % timeoutCount;
        while (true) { 
            int timeout = sleepTimeouts[i];
            i += 1;
            i = i % timeoutCount;
 
            Thread.sleep(timeout);
 
            if (watch.elapsedMillis() > milliseconds) {
                return; 
            } 
 
Contextual code suggestions in your IDE  Get Codota for Java