Delaying a Program

Question:
Can you please tell me how to delay the program flow in Java? I can’t find any implementation of delay().

Answer:
To introduce a delay into your program, use theThread.sleep method. It takes an integer argumentspecifying the number of milliseconds to delay the current thread ofexecution. If you call this method from your main application thread,it will delay your program for the specified period of time.Remember, Thread.sleep is a static method and does notrequire a reference to a Thread instance.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: