title: How does SyncLock Works in .Net
body: <p>I have a List of objects shared by multiple threads, it sometimes generate IndexOutOfRangeException when trying to <code>Clear</code>. While searching for solution I found that I should use SyncLock while accessing the List.</p>
  
  <p>But my question if what is the importance of <code>lockObject</code> in <code>SyncLock</code> block
  e.g. while clearing <code>myList</code>
  can I use</p>
  
  <pre><code>Synclock myList
      myList.Clear
  End SyncLock
  </code></pre>
  
  <p>or lockObject should be different from myList?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>What I think about sysnclock is "lock is obtained for object specified as lockObject". What if I specify list to be cleared as lockObject, shouldn't the compiler supposed to obtain the exclusive access to list before clearing it ? </p>