sending message on various timezones

S

sri mallu

I am writing an application which would send a message for a
particular country at midnight (localtime). I have about 100 such
countries and I have to also be mindful of daylight savings. I can
only think of 2 ways to do this: 1. Create a corresponding thread for
each country and which wakes up every hour or so and checks if it is
midnight(local time) and send out the message. So essentially, I will
be creating 100 threads doing nothing most of the time.
2. In this approach, there will be only one timer which checks every
minute or 30 secs the local time for 100 countries and send message.
There will need to be some extra logic as there will never be an exact
midnight match.
Not sure, if there is any better way to tackle above situation. It
would be great if I can get some ideas/suggestions here.
Thanks, SP.
 
M

Marcel Müller

sri said:
I am writing an application which would send a message for a
particular country at midnight (localtime). I have about 100 such
countries and I have to also be mindful of daylight savings. I can
only think of 2 ways to do this: 1. Create a corresponding thread for
each country and which wakes up every hour or so and checks if it is
midnight(local time) and send out the message. So essentially, I will
be creating 100 threads doing nothing most of the time.

You do not really want to do this.

2. In this approach, there will be only one timer which checks every
minute or 30 secs the local time for 100 countries and send message.
There will need to be some extra logic as there will never be an exact
midnight match.

A mail will never arrive at an exact time.

The "sent" time stamp can be set by your application to any arbitrary
value, including 0:00 in any time zone.
Not sure, if there is any better way to tackle above situation.

1. Sort the countries by the time zone offsets in a ring buffer.
2. Send mails for the countries that currently have midnight. When done,
wait for the time when the next country in the ring buffer has midnight
and continue with step 3.
3 If you reach the end of the buffer start over at the beginning.


Marcel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top