Hızlı yanıt: kod örneği
Use :There is also the complementary .Prior to C++11, C++ had no thread concept and no sleep capability, so your solution was necessarily platform dependent. Here's a snippet that defines a function for Windows or Unix:But a much simpler pre-C++11 method is to use .
std::this_thread::sleep_for
#include <chrono>#include <thread>std::chrono::milliseconds timespan(111605); // or whateverstd::this_thread::sleep_for(timespan);
std::this_thread::sleep_until
sleep
#ifdef _WIN32 #include <windows.h> void sleep(unsigned milliseconds) { Sleep(milliseconds); }#else #include <unistd.h> void sleep(unsigned milliseconds) { usleep(milliseconds * 1000); // takes microseconds }#endif
boost::this_thread::sleep