C++ Threads

Thread Example

 * 1) include 

struct thread_function { // callable type ThreadFunction(bool & completed) : completed_(completed) {} void operator { int x = 0; while(x++ < 10) { boost::this_thread::sleep(boost::posix_time::milliseconds(100)); }       completed_ = true; }   bool & completed_; };

...   bool thread_completed = false; thread_function tf(thread_completed); boost::thread new_thread(tf);

while( ! thread_completed) boost::this_thread::sleep(boost::posix_time::seconds(1));

// thread is completed, we can join the thread thread->join; delete thread;