@@ -76,28 +76,30 @@ int main(int argc, const char * argv[]) {
7676 std::auto_ptr<pthread::thread> pt0 (new pthread::thread (w));
7777 pt0->join ();
7878
79- std::list<std::auto_ptr<pthread::thread>> threads;
79+ // std::list<std::auto_ptr<pthread::thread>> threads;
80+ std::list<pthread::thread> threads;
8081 for (auto x = 20 ; x > 0 ; x--){
81- threads.push_back (std::auto_ptr<pthread::thread>(new pthread::thread (w)));
82+ // threads.push_back(std::auto_ptr<pthread::thread>(new pthread::thread(w)));
83+ threads.push_back (ibm::move (pthread::thread (w)));
8284 }
8385// threads.push_back(pthread::thread(w));
8486// threads.push_back(pthread::thread(w));
8587// threads.push_back(pthread::thread(w));
8688// threads.push_back(pthread::thread(worker("herbert's worker")));
87-
88- message (" increment counter" );
89- for ( auto x = 20000 ; x > 0 ; x--){
90- pthread::lock_guard<pthread::mutex> lck (mtx);
91- counter++ ;
92- condition.notify_one ();
93- }
94- message (" main is waiting for threads to finish" );
95-
96- std::list<std::auto_ptr<pthread::thread>>::iterator iterator;
97- for (iterator = threads.begin (); iterator != threads.end (); iterator++){
98- message (" join a thread (loop)" );
99- (*iterator)->join ();
100- }
89+ //
90+ // message("increment counter");
91+ // for ( auto x = 20000 ; x > 0 ; x--){
92+ // pthread::lock_guard<pthread::mutex> lck(mtx);
93+ // counter++ ;
94+ // condition.notify_one();
95+ // }
96+ // message("main is waiting for threads to finish");
97+ //
98+ // std::list<std::auto_ptr<pthread::thread>>::iterator iterator;
99+ // for(iterator = threads.begin(); iterator != threads.end(); iterator++){
100+ // message("join a thread (loop)");
101+ // (*iterator)->join();
102+ // }
101103
102104 message ( " end reached" );
103105
0 commit comments