title: Fastest Way for Java to write mutexes?
body: <p><a href="http://en.wikipedia.org/wiki/Mutual_exclusion" rel="nofollow noreferrer">Mutexes</a> are pretty common in many programming languages, like e.g. C/C++. I miss them in Java. However, there are multiple ways I could write my own <code>class Mutex</code>:</p>
  
  <ul>
  <li>Using a simple synchronized keyword on <code>Mutex</code>.</li>
  <li>Using a binary <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/Semaphore.html" rel="nofollow noreferrer">semaphore</a>.</li>
  <li>Using atomic variables, like discussed <a href="https://stackoverflow.com/questions/4938617/implement-a-mutex-in-java-using-atomic-variables">here</a>.</li>
  <li>...?</li>
  </ul>
  
  <p>What is the <strong>fastest (best runtime)</strong> way? I think synchronized is most common, but what about performance?</p>