64,654
社区成员
发帖
与我相关
我的任务
分享
const DWORD busytime=10;
const DWORD idletime=busytime;
DWORD starttime=0;
while(true)
{
DWORD starttime=GetTickCount();
//busyloop
while(GetTickCount()-starttime<=busytime)
;
//idleloop
Sleep(idletime);
}
const DWORD idletime=10; //在这里用DWORD是为了防止16位不够用@@
while(true)
{
clock_t start=clock();
while(clock()-start<0.1*CLOCKS_PER_SEC) ; //为什么用0.01不行呢
Sleep(idletime);
}