Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java wait

// Sleep 1 second
TimeUnit.SECONDS.sleep(1);
// Sleep 1 minute
TimeUnit.MINUTES.sleep(1);
Comment

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
Comment

wait method in java

java.lang.Object.wait() causes current thread to wait until another thread 
invokes the notify() method or the notifyAll() method for this object.
Comment

PREVIOUS NEXT
Code Example
Java :: how to create an entry in java 
Java :: arraylist 
Java :: abstract code in java 
Java :: why enable multidex android 
Java :: java queue implementation 
Java :: how to convert string to int in java 
Java :: how to use map, filter and reduce in Java 
Java :: java get enum by ordinal 
Java :: priority queue java comparator 
Java :: java read file from command line argument 
Java :: java string vers int 
Java :: queue.isempty java 
Java :: how to create hashmap 
Java :: java check if string ends with 
Java :: flutter unable to find bundled java version 
Java :: Java How to use Queue? 
Java :: Missing artifact com.sun.jersey:jersey-servlet:jar:1.20-SNAPSHOT 
Java :: round decimals in java string 
Java :: jdialog middle of screen 
Java :: stream.concat 
Java :: how to covert array into a char 
Java :: how to return the first character in an array from a method java 
Java :: boolean 
Java :: Iterating Through the Java Map 
Java :: java class array of objects 
Java :: String Reverse Program in Java. 
Java :: Send keybord key P in selenium java 
Java :: java noverify 
Java :: Java Creating ArrayBlockingQueue 
Java :: horizontalAlignment center jlabel 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =