File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread sleep times (Zzzzzzz)

 
James MacDonald-Fawcett
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
try


and your thread should be sleeping between two and four seconds.
 
Nick George
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic