title: Changing object property by function call a thread in C++
body: <p>How can I change the property of <code>av1</code> from calling a method within a thread? C++  In this code, compiler is normal but in runtime is generated a fatal error.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include&lt;thread&gt;
  
  using namespace std;
  
  class Airplane{
  
  public:
      int vel = 0;
  
      Airplane *air1;
  
      void change_av1(){
          air1-&gt;vel = 3;
          cout &lt;&lt; air1-&gt;vel &lt;&lt; endl;
          system("pause");
      }
  };
  
  void myFunction();
  
   int main(){
  
      Airplane *air1=new Airplane();
  
          myFunction();
  
      return 0;
  }
  
  void myFunction(){
  
       Airplane *object=new Airplane();
  
      thread first(&amp;Airplane::change_av1, object); // meu método dentro da thread
  
      first.join();
  }
  </code></pre>