C++ (Qt)m_finished = true;
C++ (Qt)#include <boost/thread.hpp>#include <boost/shared_ptr.hpp>#include <boost/bind.hpp>#include <iostream> class Thread{public: Thread() : m_finished( true ) {} void start() { m_th.reset( new boost::thread( boost::bind( &Thread::thread_func, this ) ) ); } void wait() { m_th->join(); } protected: virtual void run() { std::cout << "Child thread-id = " << boost::this_thread::get_id() << std::endl; } private: boost::shared_ptr<boost::thread> m_th; bool m_finished; void thread_func() { m_finished = false; run(); m_finished = true; }}; int main(){ std::cout << "Main thread-id = " << boost::this_thread::get_id() << std::endl; Thread t; t.start(); t.wait(); return 0;}
C++ (Qt)Thread t;t.start();if (t.m_finished) printf("Уже? :-)");
C++ (Qt) std::thread th(foo); if (th.get_id() == std::thread::id()) printf("finished");
C++ (Qt) void thread_func() { m_finished = false; run(); m_finished = true; }