【Boost】boost库中sleep方法详解

boost库中sleep有两个方法:
1. 这个方法只能在线程中用, 在主线程中用无效. 
原型:

[cpp]  view plain copy print ?
  1. void sleep(TimeDuration const& rel_time);  
  2. void sleep(system_time const& abs_time);  
实例:
[cpp]  view plain copy print ?
  1. boost::this_thread::sleep(boost::posix_time::seconds(2));    // 这种更好用  
  2. boost::this_thread::sleep(boost::get_system_time() + boost::posix_time::seconds(2));  
2. 在主线程中使用
原型:

[cpp]  view plain copy print ?
  1. sleep(const system_time& xt);  
实例:
[cpp]  view plain copy print ?
  1. boost::thread::sleep(boost::get_system_time() + boost::posix_time::seconds(5));  

你可能感兴趣的:(c/c++,boost)