java wait 2 seconds

try        
{
    Thread.sleep(1000);
} 
catch(InterruptedException ex) 
{
    Thread.currentThread().interrupt();
}

3.38
8
Rubixphys12 15320 points

                                    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..   	
}

3.38 (8 Votes)
0
3.8
5
Awgiedawgie 440220 points

                                    /** from: java.util.concurrent.TimeUnit **/

// Sleep for 1 second
TimeUnit.SECONDS.sleep(1);

// Sleep for 1 minute
TimeUnit.MINUTES.sleep(1);

3.8 (5 Votes)
0
4.5
8
Awgiedawgie 440220 points

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

4.5 (8 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
java delay for time creating a delay in java java delay timer java how delay java sleep every second how many seconds wait method java how to use the delay time the java wait in seconds java delay functions in java how to add a delay in seconds in java delay command java make time delay java java command for a delay delay java sleep java wait 10 seconds how to do a delay on java java delay metohds how to put 1 second pause in java delay in seconds in java wait one second java code] delay a function in java delay a function in javas how to make a timer delay in java java delay in seconds call a delay in a method java java how to add a delay add delay in java how to pause for a second in java how to delay a function in java delay one second java make code wait 1 second java set delay in java how to wait in java for 1 second java time delay method time delay java wait java 1 second how to give delay in java java built in delay java delay execution in java java timer delay how to make a program pause for a second java wait for 1 second in java put delay on java how to make a second pause in java create delay in javas Time delay in java? delay time in java wait for a delay java delay timer java wait for 1 second java delay a function call in java java wait example seconds java execution.delay delay java timer java delay example time delay in program java java delay for java delay in ode java easy delay how to delay time in java delay a method in java how to add an delay in java how to wait delay time java delay program java java time delay sleep timer delay java how to put a delay in java java code delay timer delay in java delayed function java how to put 5 seconds delay in java java adding delay to method how to make a delay java how to delay a method in java add a sleep to command java how to make java wait 1 second java system wait ms to print without exception java add delay java delay thread unity delay 1 second how to make java wait java wait 1 second in loop delay process in java java make a program wait java how to sleep a task java how to make delay in java java wait 3 seconds java sleep step java delay function java wait sec java wait for 5 seconds java add time delay sleep java 1 second java sleep wait java how to make a program wait Java Thread.sleep 1 second java how to add delay java wait in a task for seconds java sleep for x seconds wait 10 seconds java sleep timer java how to make a sleep in java sleep each 5 request java timer.sleep java how to add a sleep timer in java java sleep for 10 milleseconds how to tell java to wait time sleep java netbeans java wait seconds before call how to wait for seconds in java delay 1000 sec in java how to use delay in java how to make a delay timer in java dalay in java make a pause in java java time delay in for delay thread in java java try for 10 seconds java set delay add delay statement in java how to delay a java program wait 2 sec java how to put time delay with java delay 5 seconds in java delay in ja how to delay in java how to make your program wait in java how to delay java console how to wait for 1 second in java how to make a java program wait for some time java dlay how to set delay in java java add a wait thread sleep seconds java wait timer in java java how to delay java sleep for 1 minute how to tell program to wait java java code late java how to add timer delay java programm 1 sek paus java 8 sleep for 1 sec java 8 wait for seconds java sleep 5 seconds how to add a wait time in java how to add a wait in java java how to make a small delay java time wait java delay 1000 milisecond java wait how to set a sleep in jaba how to wait time in java how to make delay java java system wait wait for 5 sec in java java pause secondes wait time java how to do a delay in java how do i add a delay in java how to do wait in java delay javas java system.wait java time delay how to do delay in java java wait a second how to get time delay in java java wait milliseconds java thread for 2 seconds waitforseconds in java sleep delay in java java utils wait for seconds java 1 second thread how to wait a few seconds in java how to delay java java delay milliseconds how to make a delay in java wait for 1 minute in java java delayt java 10 second delay how to wait 30 seconds in java making program pause java how to wait for a second in java java wait for 10 seconds how to put delay in java add delay of 1 second in java how to delay execution in java waiting for seconds java java wait for time java wait 2 second java delay 2 seconds java delay time how to have a delay in java command to wait for a period of time in java java make a delay how to provide delay in java time.wait in java java thread wait 1 s delay function java create delay in java how to make a system wait in java java delay 1 second java sleep 3 seconds before sleep one second java java wait one second wait a minute in java java wait for 1 second java sleep 1 seconds deayed 5s on java java cause time delay how to add delay in java java how to wait some time delay 2 seconds java java how to delay execution wait 10 seconds in java wait 10 seconds in javaa wait x seconds java how to make a wait function in java how to wait in java for a second java 8 wait how to wait seconds in java how to wait 5 seconds and prints loading on java java pause for 1 second java create a small delay wait one second java add sleep in java java wait 1 min thread to sleep for 5 seconds add delay in java code wait a second java delay vs sleep in java thread. sleep java 5 sec java make program wait java wait for ms java wait seconds no thread sleep java pause 10 seconds add a delay in java java how to delay code delay in thread java wait seconds java make java program wait for a second how to add time dealy in java java time.wait java wait for 2 seconds how to wait in java code delay java code execution stack overflow java sleep seconds hoe to wait a second java java wait for 1 minute time delay in java How to make java application wait java how to do something after five seconds without sleep set a wait in java java wait 1 sec java wait x seconds java how to add a wait wait 5 seconds java how to delay before joining again in java wait 3 seconds java how to wait java how to make code wait in java java wait for a certain amount of time how to set a delay in java java sleep for 1 second pause java program for 1 second java wait 5 seconds java pause for 5 seconds +1 sconad java how to make the program wait in java make java program wait wait 2 seconds java java set time sleep java wait 2 seconds how to wait 1 second in java java wait 100ms wait for 1 sec in java java pause seconds java make delay java delay code delay in java code java make method wait java wait pause how to make java program wait for some time java how to set delay how to wait a second in java system wait java wait time in java make java wait for 1 second java wait 15 seconds wait for 5 secods in java how to delay your code for a few seconds in java without sleep how to delay your code for a few seconds in java how to make a time delay in java how to add a delay in java while how to put delay java java wait 100 ms how to wait in java java add a delay sleep java program for 15 seconds delay method java how to wait a certain amount of time in java Thread.Sleep for 10 secs java java wait seconds delay format java sleep for 5 seconds java java how to wait for 1 second java pause x second java pause 1 second make program wait java java sleep 1 second how to delay code in jdk 1.8 java wait statement java delay execution sleep for 10 seconds in java java create a delay java 5 second delay java sleep thread 1 second java wait 1 second java thread delay waitforseconds java wait 3 seconds in java java wait 30 seconds deley java java wait 10 ms delay in java method with or without using thread java wait time wait 1 second java java program wait java wait for seconds java delays wait for seconds java how to add a delay in java java delay for seconds java delay action add delay java function thread delay java java wait for some time delay java delay in java java delay
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source