This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Thread sleep times (Zzzzzzz) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Thread sleep times (Zzzzzzz)" Watch "Thread sleep times (Zzzzzzz)" New topic
Author

Thread sleep times (Zzzzzzz)

James MacDonald-Fawcett
Greenhorn

Joined: Nov 17, 2003
Posts: 4
Hi, Can anyone help me figure this out please with thread sleep times. I want to make the thread sleep for a random time. but make the time betweem two boundaires. e.g. make the thread sleep between two and four seconds.
Currently I am doing this

but this only works for a single random number. Please help thanks!
Tom Wolve
Ranch Hand

Joined: Sep 22, 2003
Posts: 32
Hi,
try


and your thread should be sleeping between two and four seconds.
Nick George
Ranch Hand

Joined: Nov 17, 2003
Posts: 38
often a good idea to surround a sleep with an try-catch:
try{
(code)
}catch(Exception e){}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread sleep times (Zzzzzzz)
 
Similar Threads
ScheduledExecutorService.scheduleAtFixedRate not doing what it is promising?
Synchronized method won't let other thread go, why?
Need to compare date time in GMT
JVM and Thread Help
Thread sleep times (Zzzzzzz)