In C++11, you can do this with standard library facilities:
#include <chrono>
#include <thread>
std::this_thread::sleep_for(std::chrono::milliseconds(x));
Clear and readable, no more need to guess at what units the sleep()
function takes.
More Related Contents:
- What’s the difference between 'gcc -g' and 'gcc -g3'?
- How to judge an address as legal or illegal by it‘s numerical value? [closed]
- How to allocate memory dynamically for class using new in C++?
- expected unqualified-id before ‘.’ token
- Easily measure elapsed time
- usr/bin/ld: cannot find -l
- C++ Dynamic Shared Library on Linux
- How to get memory usage at runtime using C++?
- Compiling multithread code with g++
- Using kbhit() and getch() on Linux
- 64 bit ntohl() in C++?
- How to increase thread priority in pthreads?
- Seeking and reading large files in a Linux C++ application
- How to disassemble a binary executable in Linux to get the assembly code?
- How to check what shared libraries are loaded at run time for a given process?
- Cancelling a thread using pthread_cancel : good practice or bad
- C++: Safe to use longjmp and setjmp?
- How to set up googleTest as a shared library on Linux
- How to get a stack trace for C++ using gcc with line number information?
- Child process receives parent’s SIGINT
- linux perf: how to interpret and find hotspots
- Linking problems due to symbols with abi::cxx11?
- Cross Platform Floating Point Consistency
- C++ error: undefined reference to ‘clock_gettime’ and ‘clock_settime’
- How to name a thread in Linux? [duplicate]
- Why is CUDA pinned memory so fast?
- Inconsistent strcmp() return value when passing strings as pointers or as literals
- Default libraries linked in by gcc?
- Undefined reference to process(std::__cxx11::basic_string … ) when compiling affdex linux sample applications
- Why do I see 400x outlier timings when calling clock_gettime repeatedly?