How to sleep a C++ Boost Thread

Depending on your version of Boost:

Either…

#include <boost/chrono.hpp>
#include <boost/thread/thread.hpp> 

boost::this_thread::sleep_for(boost::chrono::milliseconds(100));

Or…

#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread/thread.hpp> 

boost::this_thread::sleep(boost::posix_time::milliseconds(100));

You can also use microseconds, seconds, minutes, hours and maybe some others, I’m not sure.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)