HOW TO SLEEP FOR IN C++
阿新 • • 發佈:2019-02-15
在使用C++11的時候,我需要對執行緒進行等待操作,下面有四種方法:
- Use
usleep
(POSIX) - Use
Sleep
(Windows) - Use Boost.Thread
- Use
std::this_thread::sleep_for
(C++11)
Method 1: Use usleep
(POSIX)
1 2 3 4 5 6 |
|
Method 2: Use Sleep
(Windows)
1 2 3 4 5 6 |
|
Method 3: Use Boost.Thread
1 2 3 4 5 |
|
Method 4: Use std::this_thread::sleep_for
(C++11)
1 2 3 4 5 6 7 |
|
參考文章: