#include <iostream>
#include <thread>
#include <chrono>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
for (int i = 0; i < 100; i++){
cout << i << " ";
this_thread::sleep_for(chrono::seconds(5));//sleep 5秒
this_thread::sleep_for(chrono::hours(1));//sleep 1小时
this_thread::sleep_for(chrono::minutes(1));//sleep 1分钟
this_thread::sleep_for(chrono::milliseconds(1));//sleep 1毫秒
}
system("pause");
return 0;
}
c++11 sleep函数使用
最新推荐文章于 2025-10-31 18:51:08 发布
本文演示了如何使用C++进行线程管理和时间控制,通过实例代码展示了不同时间单位的线程睡眠功能。
1万+

被折叠的 条评论
为什么被折叠?



