Java Sleep sleepFor(int delay )

Here you can find the source of sleepFor(int delay )

Description

Sleeps the current thread for the given amount of milliseconds.

License

Open Source License

Parameter

Parameter Description
delay a parameter

Declaration

public static void sleepFor(int delay ) 

Method Source Code

//package com.java2s;
/******************************************************************************* 
 * Copyright (c) 2011 Red Hat, Inc. /*  w w  w  . j a v a2s  .c  o  m*/
 * Distributed under license by Red Hat, Inc. All rights reserved. 
 * This program is made available under the terms of the 
 * Eclipse Public License v1.0 which accompanies this distribution, 
 * and is available at http://www.eclipse.org/legal/epl-v10.html 
 * 
 * Contributors: 
 * Red Hat, Inc. - initial API and implementation 
 ******************************************************************************/

public class Main {
    private static final int SLEEP_DELAY = 200;

    /**
     * Sleeps the current thread for the given amount of milliseconds. InterruptedException are swallowed.
     * 
     * @param delay
     */
    public static void sleepFor(int delay /* in ms */) {
        int x = 0;
        while (x < delay) {
            x += SLEEP_DELAY;
            try {
                Thread.sleep(SLEEP_DELAY);
            } catch (InterruptedException ie) {
            }
        }
    }
}

Related

  1. sleepButInterruptable(long msecs)
  2. sleepCurrentThread()
  3. sleepDeep(long millis)
  4. sleepExp(int countFailures)
  5. sleepFixed(int milliSecond)
  6. sleepFor(int sleepDurationInMilliseconds)
  7. sleepFor(long millis)
  8. sleepForAuditGranularity()
  9. sleepForever()