This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Java in General and the fly likes delay Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "delay" Watch "delay" New topic


Lucy Sommerman
Ranch Hand

Joined: Nov 25, 2004
Posts: 61
What's the best way to add 10 second delay withing main () if not using threading?

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42956

will do that even in a single-threaded application.
Sravan Kumar
Ranch Hand

Joined: Sep 11, 2005
Posts: 121
Thread.sleep(10000) will do. sleep() method is static in Thread class and it causes the current thread to sleep for the specified number of milli-seconds.

keep smilin :: sravan<br /><a href="" target="_blank" rel="nofollow">I scribble here</a>
subject: delay
It's not a secret anymore!