title: Locking mutex in one thread and unlocking it in the other
body: <p>Will this code be correct and portable?</p>
  
  <pre><code>void* aThread(void*)
  {
      while(conditionA)
      {
          pthread_mutex_lock(mutex1);
          //do something
          pthread_mutex_unlock(mutex2);
      }
  }
  
  void* bThread(void*)
  {
      while(conditionB)
      {
          pthread_mutex_lock(mutex2);
          //do something
          pthread_mutex_unlock(mutex1);
      }
  }
  </code></pre>
  
  <p>In the actual application I have three threads - two for adding values to an array and one for reading them. And I need the third thread to display the contents of the array right after one of the other threads adds a new item.</p>