Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Strange behaviour with sleep() in a thread...

Thread Tools

Strange behaviour with sleep() in a thread...

Just Another Victim of the Ambient Morality
Posts: n/a
I have a thread created with that does some polling. I don't
want it to busy wait so I call the sleep method like so:


...this should allow me to poll every minute which is good enough for my
application. However, I'm finding that calling sleep from a thread in this
manner often sleeps for a good deal longer than a minute. So far, I find it
sleeping for about 8 or so minutes. The main thread is blocked in a gets
What I'm actually trying to do is implement a simple timer. I'm trying
to do something at a certain point in time, like a cron job, without busy
Why is sleep behaving so strangely? Is there a simple way of doing what
I'm trying to do?
Thank you...

Reply With Quote
Roger Pack
Posts: n/a

> Why is sleep behaving so strangely? Is there a simple way of doing
> what

If you're on 1.8.x then your two threads are actually one "real thread"
running two green threads. One of the green threads [the gets] might be
blocking and not allowing control to return to the other.
Fix (should this be the case): make the one not block, or use 1.9
Posted via

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
debugger behaviour different to execution behaviour Andy Chambers Java 1 05-14-2007 09:51 AM
a strange behaviour of FF Maurice Firefox 2 03-11-2005 11:53 PM
Strange mouse behaviour with flash in Mozilla 1.3.7 hpoppe Firefox 0 11-07-2004 12:16 PM
Strange taskbar behaviour (notification area) Falcon Wireless Networking 0 08-17-2004 09:03 AM
[mozilla1.6] strange behaviour with newsgroup joost68 Firefox 5 04-03-2004 03:48 AM