java wait 2 seconds

Solutions on MaxInterview for java wait 2 seconds by the best coders in the world

showing results for - "java wait 2 seconds"
Valeria
14 Jan 2018
1try        
2{
3    Thread.sleep(1000);
4} 
5catch(InterruptedException ex) 
6{
7    Thread.currentThread().interrupt();
8}
9
Vanessa
12 Jan 2020
1Syntax :
2=========================================================
3	Thread.sleep(1000); // 1000 milliseconds..          |
4=========================================================
5int i=0;
6for(;;){
7	Thread.sleep(2000); // set time delay to 2 seconds.. 
8  	System.out.println(i++); // output : every output will display after 2 seconds..   	
9}
Marco
29 Oct 2017
1/** from: java.util.concurrent.TimeUnit **/
2
3// Sleep for 1 second
4TimeUnit.SECONDS.sleep(1);
5
6// Sleep for 1 minute
7TimeUnit.MINUTES.sleep(1);
similar questions
queries leading to this page
java wait 2 seconds