title: How to debug a rare deadlock?
body: <p>I'm trying to debug a custom thread pool implementation that has <em>rarely</em> deadlocks.  So I cannot use a debugger like gdb because I have click like 100 times "launch" debugger before having a deadlock.</p>
  
  <p>Currently, I'm running the threadpool test in an infinite loop in a shell script, but that means I cannot see variables and so on.  I'm trying to <code>std::cout</code> data, but that slow down the thread and reduce the risk of deadlocks meaning that I can wait like 1hour with my infinite before getting messages.  Then I don't get the error, and I need more messages, which means waiting one more hour...</p>
  
  <p>How to efficiently debug the program so that its restart over and over until it deadlocks ?  (Or maybe should I open another question with all the code for some help ?)</p>
  
  <p>Thank you in advance !</p>
  
  <p>Bonus question : how to check everything goes fine with a <code>std::condition_variable</code> ?  You cannot really tell which thread are asleep or if a race condition occurs on the <code>wait</code> condition.</p>