J
Just Another Victim of the Ambient Morality
I have a thread created with Thread.new that does some polling. I don't
want it to busy wait so I call the sleep method like so:
sleep(60)
...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
call.
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
waiting.
Why is sleep behaving so strangely? Is there a simple way of doing what
I'm trying to do?
Thank you...
want it to busy wait so I call the sleep method like so:
sleep(60)
...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
call.
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
waiting.
Why is sleep behaving so strangely? Is there a simple way of doing what
I'm trying to do?
Thank you...