Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making the main thread sleep 1

Status
Not open for further replies.

bardley

Programmer
May 8, 2001
121
US
I was wondering...

If you have a reference to a thread, you can tell that thread to sleep. Is it possible to make the thread that's running your main method sleep?

i.e., if I wrote HelloWorld.java with only a main method that contained a continuous loop that printed "Hello World" over and over again, is there a way to tell main to sleep so that it would wait a few seconds before printing the next "Hello World"?

Brad Gunsalus
bardley90@hotmail.com
 
This will work ::

try {
Thread.sleep(10);
} catch (InterruptedException ie) {
//error
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top