Sleep for seconds seconds, without the exceptions - Java java.lang

Java examples for java.lang:Exception

Description

Sleep for seconds seconds, without the exceptions

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int seconds = 2;
        sleepSeconds(seconds);/*from ww w.  j  av a 2  s.c  o  m*/
    }

    /**
     * Sleep for <i>seconds</i> seconds, without the exceptions
     *
     */
    public final static void sleepSeconds(int seconds) {
        sleep(seconds * 1000);
    }

    /**
     * Same as Thread.sleep(), but without the exceptions
     *
     */
    public final static void sleep(long milliseconds) {
        try {
            Thread.sleep(milliseconds);
        } catch (Exception ex) {

        }
    }
}

Related Tutorials