aspose file tools*
The moose likes Beginning Java and the fly likes Help with Thread.sleep() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with Thread.sleep()" Watch "Help with Thread.sleep()" New topic
Author

Help with Thread.sleep()

Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
I want to run the following code but with the condition that after sending each 500 emails thread should sleep for 14 seconds and then start sending to next 500 emails until it finish

Any help will be highly appreciated

Thanks & best regards


[ October 16, 2008: Message edited by: Farakh khan ]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

You're already using a variable to keep count, so just use it:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Rob I am really grateful to your favorable reply

I want to clear my concept that what does that mean
if (count > 0 && count % 500 == 0)

Thanks again & Regard
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

count % 500 == 0 means that count is a multiple of 500. You should search on the modulo or remainder operator - you'll really appreciate it.

As for the count > 0, I put that in to make sure that you won't start with a 14 second sleep - since 0 is also a multiple of 500.
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
wow! great!
really appreciated

Thanks a lot
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help with Thread.sleep()