title: Mutex in JNI using Foundation NSLock
body: <p>I have some objective-c code that uses an NSLock to implement a sort of transaction.  The object is locked on a "begin transaction", several other calls are made with the lock in place, and then it's released with a "commit".  I'm writing a JNI glue layer to access this code from Java, but the lock is behaving differently in JNI vs pure objc code.</p>
  
  <p>I have unit tests in both Java and objc that exercise the code that makes the lock.  The objc test passes, but in the Java test [anNSLock tryLock] returns false even though [anNSLock lock] hasn't been called.</p>
  
  <p>Is there a recommended way to have a mutex in JNI?  I'm not sure what the underlying mechanism for NSLock is.</p>
  
  <p>Thanks!</p>