Difference between Thread.Sleep(0) and Thread.Yield()
Posted
by Xose Lluis
on Stack Overflow
See other posts from Stack Overflow
or by Xose Lluis
Published on 2010-06-02T10:51:34Z
Indexed on
2010/06/02
11:54 UTC
Read the original article
Hit count: 689
As Java has had Sleep and Yield from long ago, I've found answers for that platform, but not for .Net
.Net 4 includes the new Thread.Yield() static method. Previously the common way to hand over the CPU to other process was Thread.Sleep(0).
Apart from Thread.Yield() returning a boolean, are there other performance, OS internals differences?
For example, I'm not sure if Thread.Sleep(0) checks if other thread is ready to run before changing the current Thread to waiting state... if that's not the case, when no other threads are ready, Thread.Sleep(0) would seem rather worse that Thread.Yield().
© Stack Overflow or respective owner