Answers for "delay java sleep"

6

java delay

Syntax :
=========================================================
	Thread.sleep(1000); // 1000 milliseconds..          |
=========================================================
int i=0;
for(;;){
	Thread.sleep(2000); // set time delay to 2 seconds.. 
  	System.out.println(i++); // output : every output will display after 2 seconds..   	
}
Posted by: Guest on May-19-2020
4

sleep() java

import java.util.concurrent.TimeUnit

try {
	TimeUnit.SECONDS.sleep(1);
}
catch (Exception e) {
	System.out.println("Oops! Something went wrong!")
}
Posted by: Guest on September-02-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language