title: Obj-C how to add lock for C++ singletion in multi-thread env?
body: <p>In my app the network request secret key exchange is written by C++ and linked by library in my xcode project. It is not thread safe, which means if two threads encrypt or decrypt at the same time then unexpected behavior will happen. I always invoke it in this way. </p>
  
  <pre><code>TnKeyChangeInstance::instance()-&gt;encrypt(inStr, outStr);
  </code></pre>
  
  <p>You know, <code>@synchronized</code> only works for <code>NSObject</code> type object, how do I add a lock for C++ code, as the above singleton? Any ideas?</p>