Recommended way to force a thread context switch?

Duncan Booth duncan.booth at invalid.invalid
Sat Jan 6 16:24:15 EST 2007


Lloyd Zusman <ljz at asfast.com> wrote:

> I have a python (2.5) program with number of worker threads, and I want
> to make sure that each of these does a context switch at appropriate
> times, to avoid starvation.  I know that I can do a time.sleep(0.001) to
> force such a switch, but I'm wondering if this is the recommended
> method.

The recommended method is to start a new thread rather than following up on 
an existing thread with an unrelated question.

Why do you think that just letting the threads run won't have the effect 
you desire? Leave it to the system to schedule the threads.



More information about the Python-list mailing list