title: Pause and resume thread from parent thread in cpp
body: <p>I am using cpp thread library. I have a parent thread T1 which has a child thread T2. T2 will only loop through some items and do some processing. I need to pause and resume T2 from T1 using functions calls from T1. T1 and T2 belongs to same class. I need this to stop processing data when a particular event comes to T1; Please don't suggest any other thread implementation library.</p>
  
  <pre><code>    C::t2_func{
        for(int i=0;i&lt;data.size();i++)
          process_data(data[i]);
      }
      C::spawn(){
         t2 = std::make_unique&lt;std::thread&gt;(std::bind(&amp;C::t2_func, this));
      }
      C::pause(){
           //pause t2
      }
      C::resume(){
           //resume t2
      }
  </code></pre>