473,387 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Thread.sleep

Uri
I would like to describe the following scenario:

1. Start a thread which write something to the screen every 5 seconds
(the thread uses the sleep method by Thread). current Windows time is
15:00.
2. change the Windows clock backwards. current time is: 14:00.
3. the thread doesn't wake up.
4. wait untill 14:01.
5. change the Windows clock forward to 16:00.
6. the thread wakes up the amount of times it missed in a row (in this
case 20 times).

Are you familier with this behaviour ?
Can you tell us what causes this ?
And the Milion dolar question: How can we overcome this issue ????
Jul 17 '05 #1
1 5770
bu****@motorola.com (Uri) wrote in
news:6d**************************@posting.google.c om:
I would like to describe the following scenario:

1. Start a thread which write something to the screen every 5 seconds
(the thread uses the sleep method by Thread). current Windows time is
15:00.
2. change the Windows clock backwards. current time is: 14:00.
3. the thread doesn't wake up.
4. wait untill 14:01.
5. change the Windows clock forward to 16:00.
6. the thread wakes up the amount of times it missed in a row (in this
case 20 times).

Are you familier with this behaviour ?
Can you tell us what causes this ?
And the Milion dolar question: How can we overcome this issue ????


I believe that Java keeps track of wakeup times on an absolute basis. Thus,
the thread (step 1) will not wake up until the time is greater than or equal
to 15:00:05. This doesn't occur until Step 5.

I can't explain Step 6, but I don't understand your comment about 20 times.
20 x 5 seconds = 100 seconds, not one minute or one hour or two hours.
--
Ian Shef
These are my personal opinions and not those of my employer.
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: Anthony Baxter | last post by:
On behalf of the Python development team and the Python community, I'm happy to announce the release of Python 2.3.1 (final). Python 2.3.1 is a pure bug fix release of Python 2.3, released in...
26
by: news.microsoft.com | last post by:
Hi, Currently I have a thread thats spinning and doing a Thread.Sleep(someTime). I was thinking of changing this to Thread.Sleep(Timeout.Infinite); then when I have actual data in a...
8
by: Cider123 | last post by:
I ran into a situation where my Window Service had to process 100,000+ files, when I first noticed I needed to tweak various routines. Everything runs fine, but here's what I ran into: In the...
4
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the...
1
by: Matthijs | last post by:
Hi, I have a problem coding a UDP Server/client. The server needs to send big amounts of data over UDP. The problem however is that you can't send as fast as you like. (All packets will be dropped...
9
by: Chris Dunaway | last post by:
According to the docs, calling Thread.Sleep(0) causes the thread to be "suspended to allow other waiting threads to execute." What happens if I call Thread.Sleep(500)? Do other threads not get a...
6
by: k.mellor | last post by:
Hi, I hope someone can help. I have written a simple form to demonstrate my problem/question. The code follows. The form starts a thread, which using delegates updates a label (Every second...
0
by: Buckaroo Banzai | last post by:
Hello, newbie here... I'm writing this program but when I click the start button which should initiate either the Hare or the Tortoise, it does not, this is the first time I use threads, so the...
9
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I've got a routine that builds a table using different queries, different SQL Tables, and adding custom fields. It takes a while to run (20 - 45 seconds) so I wrote a thread to handle the table...
2
by: Steve | last post by:
Hi All, I've been trying to come up with a good way to run a certain process at a timed interval (say every 5 mins) using the SLEEP command and a semaphore flag. The basic thread loop was always...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.