title: Atomicity - Lock Vs atomic Vs binary-semaphore - Performance
body: <p><a href="https://en.wikipedia.org/wiki/Monitor_(synchronization)" rel="nofollow noreferrer">Monitor</a> = mutex(lock) + condition variable</p>
  
  <p>Each Java object has a monitor, holding above principle.</p>
  
  <p><code>synchronized</code> key word claim a monitor(lock + conditionvar) of an object. </p>
  
  <p>My understanding is, for atomicity, conditionvar is not required, lock(mutex) would suffice. </p>
  
  <hr>
  
  <p>To maintain atomicity of a memory area, Java provides <a href="https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/Lock.html" rel="nofollow noreferrer">Lock</a> , <a href="https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/package-tree.html" rel="nofollow noreferrer">atomic</a> package and <a href="https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Semaphore.html" rel="nofollow noreferrer">binary semaphore</a>.</p>
  
  <p>For atomicity, Which approach is better in terms of performance?</p>