title: access to a thread variable from main loop - c++ - windows
body: <p>I'm completely new to the concept of thread.</p>
  
  <p>I have to use a thread to update some cv::mat variable from camera from my main program.</p>
  
  <p>I only know that thread mean problem to share variable :/</p>
  
  <p>So I think that I can't use a general variable in both my main and in the thread</p>
  
  <p>I'm using </p>
  
  <pre><code>    #include &lt;thread&gt; 
  </code></pre>
  
  <p>Here is my thread fct:</p>
  
  <pre><code>    void MyThreadFunction()
      {
          cv::Mat a;
          cv::Mat b;
  
          while (1)
          {
              capture_L.read(a);
              capture_R.read(b);
          }
  
      }
  </code></pre>
  
  <p>I'm calling it before entering in my main loop(for rendering). So my goal is to access a and b in my main function. How can I do that?</p>