// mutex_test.cpp : Defines the entry point for the console application. // #include #include #include namespace pt = boost::posix_time; #include "error_handling.h" boost::timed_mutex mutex; void thread_func() { while (!boost::this_thread::interruption_requested()) { boost::timed_mutex::scoped_lock lock(mutex, pt::milliseconds(1)); boost::this_thread::sleep(pt::milliseconds(1)); } } int main(int argc, char* argv[]) { setup_error_handling(); boost::thread_group tg; for (size_t i = 0; i != 20; ++i) tg.create_thread(thread_func); boost::this_thread::sleep(pt::minutes(1)); tg.interrupt_all(); tg.join_all(); std::cout << "\nfinished\n"; return 0; }