博客轉載自:https://blog.csdn.net/huang_xw/article/details/8453506
boost庫中sleep有兩個方法:
1. 這個方法只能在線程中用, 在主線程中用無效.
void sleep(TimeDuration const& rel_time); void sleep(system_time const& abs_time);
實例:
boost::this_thread::sleep(boost::posix_time::seconds(2)); // 這種更好用 boost::this_thread::sleep(boost::get_system_time() + boost::posix_time::seconds(2));
2. 在主線程中使用
原型:
sleep(const system_time& xt);
實例:
boost::thread::sleep(boost::get_system_time() + boost::posix_time::seconds(5));