Answers for "how to create a pause in java"

0

java pause

//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
Posted by: Guest on July-07-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language