Is Thread.Yield a standard way to determine if you have a bug in your multi threaded application C#

Viewed 889

I began reading through the information posted at http://www.albahari.com/threading/

The author stated that:

Sleep(0) or Yield is occasionally useful in production code for advanced performance tweaks. It’s also an excellent diagnostic tool for helping to uncover thread safety issues: if inserting Thread.Yield() anywhere in your code makes or breaks the program, you almost certainly have a bug.

According to the MSDN on Thread.Yield(), Thread.Yield() is defined as follows:

Causes the calling thread to yield execution to another thread that is ready to run on the current processor. The operating system selects the thread to yield to.

To me, this describes the half of software development that says that race conditions can't be solved.

Is this a standard debugging practice in threading?

3 Answers
Related