Thread.spinWait()有什么作用?MSDN里面没讲清楚!

heavenkiller 2003-07-28 09:56:18
Thread.spinWait()有什么作用?MSDN里面没讲清楚!
...全文
344 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
cloudtarget 2003-09-26
  • 打赏
  • 举报
回复
MSDN
jennyq_zq 2003-07-30
  • 打赏
  • 举报
回复
Of course you can write a function to do busy waiting based on time. But I really doubt whether it makes sense. Even spinwait is rarely used, because it only can beats sleep when the thread needs to wait less time than the time of context switch.
heavenkiller 2003-07-29
  • 打赏
  • 举报
回复
有没有什么方法是使某个线程独自执行多少时间,而不是阻塞多少时间的?
jennyq_zq 2003-07-29
  • 打赏
  • 举报
回复
spinwait is like executing a loop, and return after the counter runs out. It is different from sleep(which would go into inactive status)that spinwait is actually let your thread execute and do nothing productive(busy waiting).

I think it is useful in situations building spinlock which is commonly used in driver development.
IceboundRock 2003-07-28
  • 打赏
  • 举报
回复
测试了一下,等待的时间比较短,但是还是和参数的大小成正比的。我想是等待指定的时钟周期数吧
heavenkiller 2003-07-28
  • 打赏
  • 举报
回复
有没有什么方法是使某个线程执行多少时间,而不是阻塞多少时间的?
heavenkiller 2003-07-28
  • 打赏
  • 举报
回复
那和Thread.Sleep就没什么区别啦,我想区别应该还是有的,只是我现在还搞不清而已!

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧