Answers for "how to delay in java"

2

java utils wait for seconds

try        
{
    Thread.sleep(1000);
} 
catch(InterruptedException ex) 
{
    Thread.currentThread().interrupt();
}
Posted by: Guest on November-18-2020
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
2

delay a function call in java

new java.util.Timer().schedule( 
        new java.util.TimerTask() {
            @Override
            public void run() {
                // your code here
            }
        }, 
        5000 
);
Posted by: Guest on August-19-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language