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 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 19655
    
  18

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: 19655
    
  18

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Help with Thread.sleep()
 
Similar Threads
java.sql.SQLException: Closed Statement: next
How to show progress?
Sending Emails
how to avoid the java.lang.IllegalStateException
Date Comparison in Java