// Sleep 1 second
TimeUnit.SECONDS.sleep(1);
// Sleep 1 minute
TimeUnit.MINUTES.sleep(1);
//1000 is the number of milliseconds (1000 milli = 1 second)
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
//Thread.sleep always throws an exception once done so this breaks
Thread.currentThread().interrupt();
}
//to make it fancy you can make a new method
public static void wait (int sec) {
sec *= 1000;
try { //scroll down
Thread.sleep(sec);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
//now just do
wait(1);
//this will wait for 1 second
java.lang.Object.wait() causes current thread to wait until another thread
invokes the notify() method or the notifyAll() method for this object.