Sleep for milliseconds

2019-01-01 05:57发布

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++ linux sleep
14条回答
高级女魔头
2楼-- · 2019-01-01 06:53
#include <windows.h>

Syntax:

Sleep (  __in DWORD dwMilliseconds   );

Usage:

Sleep (1000); //Sleeps for 1000 ms or 1 sec
查看更多
琉璃瓶的回忆
3楼-- · 2019-01-01 06:54

Depending on your platform you may have usleep or nanosleep available. usleep is deprecated and has been deleted from the most recent POSIX standard; nanosleep is preferred.

查看更多
登录 后发表回答