title: updated value of member variable is not reflacted within thread routin function in pthread
body: <pre><code>void MyThread::startThread()
  {
      bStopThread = 0;
      pthread_attr_t attr;
      pthread_attr_init(&amp;attr);
      pthread_attr_setdetachedstate(&amp;attr, PTHREAD_CREATE_JOINABLE);
      pthread_create(&amp;threadID, &amp;attr, threadFunc, this);
  }
  
  void MyThread::stopThread()
  {
      bStopThread = 1;
  }
  
  void* MyThread::threadFunc(void* arg)
  {
      MyThread* myThread = reinterpret_cast&lt;MyThread*&gt;(arg);
  
      while(myThread-&gt;bStopThread == 0)
      {
  
      }
  }
  </code></pre>
  
  <p>In above Code Sample, I am trying to get out of the while loop, implemented in thread routine function, when I call <code>stopThread</code> function. but when I am testing this code, my boolean variable is changed in <code>stopThread</code> function but its not reflected in thread routine function. Can anyone help me on this. What goes wrong here. I am compiling this code in android jni using NDK. I tried mentioning <code>volatile</code> type for <code>bStopThread</code> variable, but its not working as well.</p>