
Hi Vicente,
[...] template<typename TimeDuration> bool timed_join(TimeDuration const& rel_time);
Preconditions:
the thread is joinable.
could you please, then, summarize what is the correct way of coping with a single thread structure from multiple threads of execution in boost 1.48? Besides locking it for synchronizing access do you think it would be safe to access the thread methods like this? (Please don't elaborate on the specific code choices, I put there some almost non-sense code, just to better illustrate my question) { end_condition = false while(not end_condition) { <get the to_be_joined_thread lock> if (to_be_joined_thread->joinable()) { result = to_be_joined_thread->timed_join(<1 second>); if (result) { end_condition = true; } } else { end_condition = true; } } } Suppose at the first round it can't join the thread, after 1 second it times out, it goes back to the beginning and tries again. Between the lock release and the new lock acquisition another thread runs the same code and it manages to join the to_be_joined_thread. When the first thread gets the lock again, what is it going to find with the joinable() call? I would expect a joinable() == false, 'cause the thread has been already joined by someone else. Am I right? A.