newbie question on threading

Aahz aahz at
Sun Oct 13 08:32:32 CEST 2002

In article <jsngquskdhc0cpg867djcna0cl6u8tlm9l at>,
Gonçalo Rodrigues  <op73418 at> wrote:
>#Balancing act: We can't afford a pure busy loop, so we
>#have to sleep; but if we sleep the whole timeout time,
>#we'll be unresponsive.
>My question is: why is a busy loop not affordable (without a sleep
>call), e.g. something like (in pseudo-code description)
>while 1:
>    <acquire lock>
>    if <acquire sucessfull>:
>        break
>    if <timedout?>:
>        break
>    <calculate endtime>

Consider this:

    while 1:

Given the above loop in a thread, how much useful work is the thread
doing?  Not much, right?  Well, adding an "if" statement to the loop
doesn't do any good for producing useful work.
Aahz (aahz at           <*>

Project Vote Smart:

More information about the Python-list mailing list