Java Program to Sleep Program Execution for Specified Milliseconds

You are currently viewing Java Program to Sleep Program Execution for Specified Milliseconds

Java program to sleep program execution for specified milliseconds

// Java program to sleep program 
// for specified milliseconds

public class Main {
  public static void main(String[] args) {
    try {
      System.out.println("Hello");
      Thread.sleep(1000);
      System.out.println("Hii");
    } catch (Exception e) {
      System.out.println(e);
    }
  }
}

Output

Hello
Hii

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply