title: Java Concurrency: CAS vs Locking
body: <p>I'm reading the Book <em>Java Concurrency in Practice</em>. In chapter 15, they are talking about the nonblocking algorithms and the <em>compare-and-swap</em> (CAS) method. </p>
  
  <p>It is written that CAS perform much better than the locking methods. <strong>I want to ask the people who already worked with both of these concepts and would like to hear when you are preferring which one of these concepts? Is it really so much faster?</strong></p>
  
  <p>For me, the usage of locks is much clearer and easier to understand and maybe even better to maintain <em>(please correct me if I am wrong)</em>. Should we really focus on creating our concurrent code related to CAS than locks to get a better performance boost or is sustainability more important?</p>
  
  <p>I know there is maybe not a strict rule when to use what. <strong>But I just would like to hear some opinions, experiences with the new concept of CAS.</strong></p>