休眠几毫秒 [英] Sleep for milliseconds
本文介绍了休眠几毫秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道 POSIX sleep(x)
函数使程序休眠 x 秒.是否有一个函数可以让程序在 C++ 中休眠 x 毫秒?
I know the POSIX sleep(x)
function makes the program sleep for x seconds. Is there a function to make the program sleep for x milliseconds in C++?
推荐答案
请注意,没有用于毫秒的标准 C API,因此(在 Unix 上)您将不得不满足于 usleep
,它接受微秒:
Note that there is no standard C API for milliseconds, so (on Unix) you will have to settle for usleep
, which accepts microseconds:
#include <unistd.h>
unsigned int microseconds;
...
usleep(microseconds);
这篇关于休眠几毫秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文