“Java Sleep 1 sekunda” Kod odpowiedzi

Java sleep 1 s.

function delay(time) {
  return new Promise(resolve => setTimeout(resolve, time));
}

delay(1000).then(() => console.log('ran after 1 second1 passed'));
Powerful Puma

Java zatrzymuje 1 sekundę

//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
YaKiCode

Opóźnienie Java

Syntax :
=========================================================
	Thread.sleep(1000); // 1000 milliseconds..          |
=========================================================
int i=0;
for(;;){
	Thread.sleep(2000); // set time delay to 2 seconds.. 
  	System.out.println(i++); // output : every output will display after 2 seconds..   	
}
dr3am_warri0r

Sleep () Java

import java.util.concurrent.TimeUnit

try {
	TimeUnit.SECONDS.sleep(1);
}
catch (Exception e) {
	System.out.println("Oops! Something went wrong!")
}
Proud Puma

Java Sleep 1 sekunda

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();
      }
    }
}
Easy Emu

Odpowiedzi podobne do “Java Sleep 1 sekunda”

Pytania podobne do “Java Sleep 1 sekunda”

Więcej pokrewnych odpowiedzi na “Java Sleep 1 sekunda” w Java

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu