SwitchToThread/Thread.Yield vs. Thread.Sleep(0) vs. Thead.Sleep(1)

后端 未结 4 1445
-上瘾入骨i
-上瘾入骨i 2020-12-13 04:25

I am trying to write the ultimate \"Yield\" method to yield the current time slice to other threads. So far I have found that there are several different ways to make the th

4条回答
  •  感动是毒
    2020-12-13 04:47

    SpinWait is design to wait without yielding the current timeslice

    It is designed for situations where you know you'll want to do something in a very short time so losing you timeslice will be excessive.

    I was under the impression Thread.Yield(x) for any value of x < the thread quantum was equivalent, including zero though I have no benchmarks to that effect.

提交回复
热议问题