- try
- {
- const int num_threads = 4;
- boost::thread_group thrds;
- for (int i=0; i < num_threads; ++i)
- thrds.create_thread(&change_count);
-
- thrds.join_all();
-
- }
- catch (std::exception &e)
- {
- std::cout << e.what() << "\n";
- exit(1);
- }
- exit(0);
+ try
+ {
+ const int num_threads = 4;
+ std::list<boost::thread *> thread_list;
+
+ for (int i=0; i < num_threads; ++i)
+ {
+ worker w;
+ thread_list.push_back(new boost::thread(w));
+ }
+ std::list<boost::thread *>::iterator it;
+ for (it = thread_list.begin(); it != thread_list.end(); it++)
+ {
+ (*it)->join();
+ delete *it;
+ }
+
+ }
+ catch (...)
+ {
+ BOOST_CHECK(false);
+ }
+ BOOST_CHECK(c.increment() == 10);