C++的自定义线程函数内调用了一个自定义的yield()接口。

在windows上是调用了SwitchToThread来实现的,linux是pthread_yield实现的。

Sleep(0):时间片只能让给优先级相同或更高的线程; 
SwitchToThread():只要有可调度线程,即便优先级较低,也会让其调度。

下面是MSDN上对Sleep函数的描述:

The time interval for which execution is to be suspended, in milliseconds.

A value of zero causes the thread to relinquish the remainder of its time slice to any other thread that is ready to run. If there are no other threads ready to run, the function returns immediately, and the thread continues execution.

Windows XP/2000:  A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution. This behavior changed starting with Windows Server 2003.

可以看到,从2003 server开始,Sleep(0)变成了调度所有可调度线程,跟SwitchToThread差不多了。

最新文章

  1. 全网独家MongoDB Certified DBA Associate考试认证视频
  2. iOS开发之窥探UICollectionViewController(五) --一款炫酷的图片浏览组件
  3. dll版本冲突的解决方法
  4. em 和 px相互转换
  5. HttpContext.Cache 详解
  6. 设计前沿:25款精妙的 iOS 应用程序图标
  7. PHP header()函数
  8. bzoj1560
  9. 不是什么时候都可以用栈来声明对象并使用(自动释放)——Delphi里到处都是编译器魔法,并且自动帮助实例化界面元素指针
  10. JS作用域就这么几句话
  11. IT(计算机/软件/互联网)专业词汇宝典(持续更新中)
  12. 微信小程序基于腾讯云对象存储的图片上传
  13. Python:黑板课爬虫闯关第五关
  14. iOS自动布局的学习
  15. docker+elasticsearch的安装
  16. inline-block 引发的间隙原因与解决方法
  17. 【Git】从服务器搭建到提交分支使用——初学者轻松上手篇
  18. HGOI20181031 模拟题解
  19. 【数据库系列】MySql中的select的锁表范围
  20. CentOS Gnome字体不清晰

热门文章

  1. MFC DLL 可以封装MFC的窗体 供别的MFC程序使用
  2. [netty4][netty-common]Future与Promise分析
  3. alert(1) to win部分解题
  4. Spring整合hibernate -hibernateTemplate
  5. 【转】tomcat与apache,tomcat与servlet的区别
  6. Unity3D 绘制扇形/环形
  7. BZOJ 3771 Triple ——FFT
  8. bzoj3680吊打GTY
  9. #ifndef 的用法介绍
  10. windows 批处理删除指定目录下 指定类型 指定天数之前文件