Pause the execution of a thread using sleep() : Sleep Pause « Thread « Java Tutorial






class Wait {
  public static void bySeconds(long s) {
    try {
      Thread.currentThread().sleep(s * 1000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}

public class Main {
  public static void main(String args[]) {
    System.out.println("Wait");
    Wait.bySeconds(5);
    System.out.println("Done");
  }
}








10.18.Sleep Pause
10.18.1.Pause the execution
10.18.2.Pausing the Current Thread: a thread can temporarily stop execution.
10.18.3.Add a delay
10.18.4.Pause the execution of a thread using sleep()