title: Client-side locking
body: <p>Following is an excerpt from JCIP </p>
  
  <p><a href="https://i.stack.imgur.com/Pf3Xv.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Pf3Xv.jpg" alt="enter image description here"></a></p>
  
  <p>The author says that in order to make the above code thread-safe we have to use client-side locking.</p>
  
  <blockquote>
    <p>To make this approach work, we have to use the same lock that the List uses by using client-side locking or external locking. Client-side locking entails guarding client code that uses some object X with the lock X uses to guard its own state. In order to use client-side locking, you must know what lock X uses.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/6yYyz.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/6yYyz.jpg" alt="enter image description here"></a></p>
  
  <p>Why can't we simply make the <strong>List&lt; E ></strong> object private in the very first place to make the ListHelper class thread-safe?</p>