title: Synchronized keyword- how it works?
body: <p>If I have a class, call it X and X contains a collection (assume I am not using one of the synchronized colections, just a normal one).</p>
  
  <p>If I was to write my own method synchronized add()- how does the locking work? Is the locking done on the instance of X, and not on the collection object?</p>
  
  <p>So synchronizing my add() method would not stop many instances of X from calling add() and inserting into the collection- therefore I could still have threading problems?</p>