--- thread.hpp.orig 2009-04-21 10:08:59.000000000 -0400 +++ thread.hpp 2009-04-21 10:18:08.000000000 -0400 @@ -530,17 +530,32 @@ } } void join_all() { - boost::lock_guard guard(m); - - for(std::list::iterator it=threads.begin(),end=threads.end(); - it!=end; - ++it) + std::list joined; + for(;;) { - (*it)->join(); + thread* t; // thread to join while mutex not held + { + boost::lock_guard guard(m); + + for(std::list::iterator it=threads.begin(),end=threads.end();;++it) + { + if(it=end) + { + return; + } + std::list::iterator const j=std::find(joined.begin(),joined.end(),*it); + if(j==joined.end()) + { + t = *it; + break; + } + } + } + t->join(); } } void interrupt_all() {