Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread Scheduling  RSS feed

 
Brian Percival
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if this is the right place for the q, feel free to export it to any other section, but here is the problem...

I have a Timer with Tasks scheduled at different times. The problem apparenty is, The firing of the events is totally based on the Time set on the server machine. And after a while I see that the server machine is getting out of sync with the real time, so 1:15 AM on the server is not really 1:15 AM but say 1:13 AM.

What should be my approach? I appreciate your thoughts..

Brian
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is probably a General Computing question ... Sounds like you need a utility that syncs your server clock to a Time Server. We use a time server within the company network, I think, but there are plenty of public ones out there, some run off the government's best atomic clocks.

This will be outside your Java app, since you can't set the system time from Java. Run it during off hours to avoid confusing your applications with a missing second.

We still don't have the !@#$% phones on a proper time server ... the little LED displays are off by 5 or 10 minutes sometimes.
[ July 24, 2007: Message edited by: Stan James ]
 
Brian Percival
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tell me about it.. My local machine time always lags by 20 min if I don't sync it back, our cisco phones have different times and our domain machines ( mine is not onthe domain) has a different time...

Well, my question is first,

How exactly are TimerTasks scheduled?? Say I scheduled a Task for 10:30 AM (when my system time is lagging by say 5 min). After scheduling the task I now synch with nist time. Then when exactly will my Task event be fired?

I am guessing when it is 10:30 AM on the local machine time, no matter what.. right?

Is there anyway we can schedule Threads not based on local machine time??

Brian...
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have never looked, but I wouldn't be surprised if when you ask Timer to schedule a job for 10:00 it computes the number of milliseconds between now and then and goes to sleep for that long. If that's what it does, then resetting the system clock after scheduling wouldn't help. Resetting it before scheduling probably would.

Any chance to escalate this problem to the higher ranks of infrastructure folks and get a company standard to sync all machines to a time server daily? Once we made the right people aware of the problem, we deployed the sync utilities to all of our servers very rapidly.
 
Brian Percival
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stan,

I tested it, it is the other way how it works looks like... If you are already off by say five min, and then you schedule the Thread for say 10:00 and then go sync the local time, the even firing apparently is done at 10:00 correctly, not at 9:55 or 10:05 ( depending on the original offset beign +/-)..

Which means the JVM puts request to the underlying OS to inturn fire an event when it is 10:00 (?) delegation sorts of...
Someone correct me if it's otherwise.

Brian
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!