C++编程之美-代码清单1-2

代码清单1-2

int busyTime = 10;           // 10 ms 
int idleTime = busyTime;    // same ratio will lead to 50% cpu usage

Int64 startTime = 0;
while(true)
{
     startTime = GetTickCount();    
     // busy loop
     while((GetTickCount() - startTime) <= busyTime)
          ;

     // idle loop
     Sleep(idleTime);
}
发布了1165 篇原创文章 · 获赞 928 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/weixin_42528266/article/details/104022706