title: Catching exception from worker thread in the main thread
body: <p>I didn't find a concise answer to the following problem:I have a producer - consumer threading model where main thread is the consumer while some worker thread is the producer.The producer thread runs it's thread loop during the application execution and it is possible for it to throw exceptions occasionally.The main thread is UI thread which should pop-up exception messages including those coming from different threads. How can I catch these exceptions in the main thread?  </p>
  
  <p>Using boost on Windows with  C++0x</p>
  
  <p><strong>WorkerThread.cpp</strong></p>
  
  <pre><code>WorkerThread::WorkerThread(){
  
     m_thread = boost::thread(&amp;WorkerThread::drawThread,this);
  
  }
  
  void WorkerThread::drawThread()
  {
  
           while(true)
           {
               boost::unique_lock&lt;boost::mutex&gt; lock(m_mutex);
                try{
  
                  ///some work is done here...
  
                }catch(std::exception &amp;e){
  
                 /// some exception is thrown
                 /// notify main thread of the exception
                }
  
           }
  
  
   }
  </code></pre>
  
  <p>Important to note that I have no ability to wrap WorkerThread in the main thread with try{}catch  as it is created at some point and from then on runs on its own till the application termination.</p>