[Qt-interest] Multithreading - yield function
Sean Harmer
sean.harmer at maps-technology.com
Tue Sep 1 12:15:33 CEST 2009
On Tuesday 01 Sep 2009 10:58:23 Patric wrote:
> Hi, msleep(1) is doing what yield should do from my point of view.
> Very tricky, though...
No. msleep(1) is just making that thread go to sleep. It just so happens that
1ms is ages for modern CPUs and so the kernel decides to switch context to
another thread/application rather than wasting a whole ms of CPU time.
The yield function just says to the kernel "you can do a context switch if you
like but I am not going to force you".
Is that clear?
Sean
More information about the Qt-interest-old
mailing list