Access a Variable of an Object from Threads
<p>I need help with my c++ programm.
I start to Threads beside the main function:</p>

<pre><code>thread Thread1(&amp;Foo::Loop1, info,std::ref(info));
thread Thread2(&amp;Foo::Loop2, info,std::ref(info));
</code></pre>

<p><code>info</code> is an object from the class <code>Foo</code> which contains <code>bool active</code></p>

<p>later I change the <code>active</code> to <code>true</code> but the value in <code>Loop1</code> or <code>Loop2</code> dont change. They are everytime the same.</p>

<p>my prototype function looks like this:</p>

<pre><code>void Loop1(Foo info);
void Loop2(Foo info);
</code></pre>

<p>the called function:</p>

<pre><code>void Foo::Loop1(Foo info){
    while (true){
        if (info.active){
          //Stuff
        }
    }
}
</code></pre>

<p>So what should I do to pass the value from the object <code>Foo</code> which change in the <code>main</code> function so the value <code>active</code> in the <code>Loop</code> functions are equal.</p>

<p>Thank you for helping :)</p>