Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java pause 1 second

//deprecated in main thread:
try {
  Thread.sleep(1000);//time is in ms (1000 ms = 1 second)
} catch (InterruptedException e) {e.printStackTrace();}

//please use bellow instead:
Timer timer = new Timer();
timer.schedule(new TimerTask() {
  @Override
  public void run() {
    //what you want to do
  }
}, 1000);//wait 1000ms before doing the action
Comment

java sleep 1 second

import java.util.Date;
public class JavaHungry {
    public static void main(String args[]) {
      try
      {
        System.out.println("Start of delay: "+ new Date());
        // Delay for 7 seonds
        Thread.sleep(7000);   
        System.out.println("End of delay: "+ new Date());
      }
      catch(InterruptedException ex)
      {
          ex.printStackTrace();
      }
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to find location of java jdk 
Java :: navigate to another activity in android 
Java :: java replace first occurrence of substring 
Java :: java nested loop 
Java :: java bean 
Java :: min height bst leetcode 
Java :: convert javascritp getTime() to datetime 
Java :: start activity for result deprecate 
Java :: java replace a character at end of string 
Java :: how to remove null values in java 
Java :: react The href attribute is required for an anchor to be keyboard 
Java :: findviewbyid in kotlin Just using id name . 
Java :: how to return array in java 
Java :: java base64 
Java :: java get length of a string 
Java :: java check palindrome with string builder 
Java :: get the length of an array java 
Java :: string format java 
Java :: how to take max value from priority queue in java 
Java :: java convert edittext to double 
Java :: hello world program in java 
Java :: string to int in java 
Java :: compare numbers in array in java 
Java :: mockito verify more than once 
Java :: java print stack 
Java :: change size of array java 
Java :: how to split string in java android 
Java :: get last string separated by / 
Java :: labelled break statement in Java 
Java :: advantages of exception handling in java 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =