boost庫中sleep方法詳解


博客轉載自: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));  

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM