std::this_thread::sleep_for() Or usleep()
What would be better to be used in main()? This may be very silly but i am new to C++11 features.
The former is actually a portable C++ function. The latter is an obsolete, non-portable POSIX function (replaced by nanosleep
, which remains non-portable). Use std::this_thread::sleep_for()
, which will likely be implemented in terms of nanosleep
when available/appropriate, or whatever other function the system provides otherwise.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.