H
huy
Hi All,
Wondering if anyone could help with this problem.
I have a label which gets updated with the time every one second using
the following code.
clockThread = new Thread()
{
public void run()
{
for (; ; ) {
jobList.clock.setText(timeFormat.format(new Date()));
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Logger.error("Clock interrupted");
}
}
}
};
I have another bit of code which updates the System time and calls
clockThread.interrupt(). I do this because I read somewhere that
Thread.sleep() operates via a fixed timestamp i.e it's 9.00.00 and
sleep(1000) will wakeup at 9.00.10, not 1 sec from now (i.e relative to
current time/moment).
The problem I am having is that if I set the time to a time past the
current time eg. 9.15.00, then the above code works and my label gets
updated. However, if I set the time to somewhere before the current time
eg. 8.30.00, then the above code does not update my label, although the
thread does get interrupted ??? Huhhh ???
My guess: something is going on in one of the AWT threads which stops
the label from being updated to the current value, but I don't know what ?
Any help is greatly appreciated.
Regards,
Huy
Wondering if anyone could help with this problem.
I have a label which gets updated with the time every one second using
the following code.
clockThread = new Thread()
{
public void run()
{
for (; ; ) {
jobList.clock.setText(timeFormat.format(new Date()));
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Logger.error("Clock interrupted");
}
}
}
};
I have another bit of code which updates the System time and calls
clockThread.interrupt(). I do this because I read somewhere that
Thread.sleep() operates via a fixed timestamp i.e it's 9.00.00 and
sleep(1000) will wakeup at 9.00.10, not 1 sec from now (i.e relative to
current time/moment).
The problem I am having is that if I set the time to a time past the
current time eg. 9.15.00, then the above code works and my label gets
updated. However, if I set the time to somewhere before the current time
eg. 8.30.00, then the above code does not update my label, although the
thread does get interrupted ??? Huhhh ???
My guess: something is going on in one of the AWT threads which stops
the label from being updated to the current value, but I don't know what ?
Any help is greatly appreciated.
Regards,
Huy