Pausing the Current Thread - Java Thread

Java examples for Thread:Thread Operation

Description

Pausing the Current Thread

Demo Code


public class Main {
  public static void main(String[] args) {
    try {/*from  w  w  w .  j  a  va  2 s.  c  om*/
      long numMillisecondsToSleep = 5000; // 5 seconds
      Thread.sleep(numMillisecondsToSleep);
    } catch (InterruptedException e) {
    }
  }
}

Related Tutorials