Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

how to wait in java

//1000 is the number of milliseconds (1000 milli = 1 second)
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
  //Thread.sleep always throws an exception once done so this breaks
  Thread.currentThread().interrupt();
}
//to make it fancy you can make a new method
public static void wait (int sec)  {
    sec *= 1000;
    try { //scroll down
  Thread.sleep(sec);
} catch (InterruptedException e) {
  Thread.currentThread().interrupt();
}
  }
//now just do
wait(1);
//this will wait for 1 second
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #wait #java
ADD COMMENT
Topic
Name
2+9 =