睡眠时间为毫秒 [英] 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屋!
查看全文