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 :: select word from array 
Java :: java or symbol 
Java :: java 8 functional interfaces 
Java :: java rock paper scissors 
Java :: java try catch 
Java :: factorial of a number using recursion in java 
Java :: solid principles in programming 
Java :: remove extra spaces java 
Java :: java 16 raspberry pi 
Java :: optional throw if present 
Java :: android use attribute color programmatically 
Java :: java string padding 
Java :: how to add elements to an empty array in java 
Java :: java export image 
Java :: arrays sort 2d array java 
Java :: android create snackbar 
Java :: java 8 list stream delete by name 
Java :: at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1565) 
Java :: n queens problem leetcode 
Java :: wait random time java 
Java :: bubble sort for java ArrayList 
Java :: static int java 
Java :: view binding in recyclerview adapter android java 
Java :: how to add input in array java 
Java :: java get year month day hour minute second 
Java :: android get list element by index 
Java :: java does file exist 
Java :: calendar.year java 
Java :: java get bigger int 
Java :: 8.1.1. Declaring an Array¶ 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =