那么,这两个是一样的吗?在任务管理器中使用延迟 CPU 使用率很疯狂。这与系统空闲进程相同吗?
#include <iostream>
#include <time.h>
//#include <windows.h>
int delay(long int time)
{
clock_t beginning = clock();
while(clock() - beginning < time) {}
return 0;
}
int main()
{
clock_t beginning = clock();
begin:
std::cout << "delay this by 1000ms\n";
//Sleep(1000);
delay(1000);
goto begin; //i know, i know
return 0;
}