Pause the execution usin Thread.sleep in Java
Description
The following code shows how to pause the execution usin Thread.sleep.
Example
//from www . j av a 2 s .c om
class Wait {
public static void oneSec() {
try {
Thread.currentThread().sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public static void manySec(long s) {
try {
Thread.currentThread().sleep(s * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public class Main{
public static void main(String args[]) {
Wait.oneSec();
Wait.manySec(5);
}
}