Difference between Thread.Sleep(0) and Thread.Yield()

前端 未结 3 1242
遥遥无期
遥遥无期 2020-12-14 08:00

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. Previous

3条回答
  •  清歌不尽
    2020-12-14 08:43

    Thread.Sleep(0) relinquishes the thread’s current time slice immediately, voluntarily handing over the CPU to other threads.

    Framework 4.0’s new Thread.Yield() method does the same thing — except that it relinquishes only to threads running on the same processor.

    source

提交回复
热议问题