Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java Language
Expertise: Beginner
Dec 4, 1998

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 the Thread.sleep method. It takes an integer argument specifying the number of milliseconds to delay the current thread of execution. 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 not require a reference to a Thread instance.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap