
On 05/12/2012 13.39, Anthony Williams wrote:
On 05/12/12 11:33, Gaetano Mendola wrote:
On 05/12/2012 09.16, Anthony Williams wrote:
On 04/12/12 18:32, Gaetano Mendola wrote:
Hi all, I was investigating a rare deadlock when issuing an interrupt and a timed_join in parallel. I come out with the the following code showing the behavior.
The deadlock is rare so sometime you need to wait a bit.
I couldn't try it with boost 1.52 because the code is invalid due the precondition of "thread joinable" when issuing the timed_join.
That's a hint.
Is the code not valid or a real bug?
The code is invalid: you keep trying to interrupt and join even after the thread has been joined! Once the thread has been joined, the thread handle is no longer valid, and you should exit the loop.
I haven't seen this statement in the documentation.
The thread object itself is not thread-safe --- a given thread object should have a single owner. Only one thread can perform an operation on that thread object at a time. If you wish to call member functions on it from multiple threads then they need synchronizing.
This is exactly what I was looking for in the documentation but I haven't find any trace of it. Now all my observations make sense. Regards Gaetano Mendola