title: VB.net SyncLock Object
body: <p>I always seen on SyncLock examples people using </p>
  
  <pre><code>    Private Lock1 As New Object ' declaration
      SyncLock Lock1 ' usage
  </code></pre>
  
  <p>but why?
  In my specific case I'm locking a Queue to avoid problems on mult-threading Enqueueing and Dequeueing my data.</p>
  
  <p>Can I lock the Queue object itself, like this?</p>
  
  <pre><code>    Private cmdQueue As New Queue(Of QueueItem) ' declaration
      SyncLock cmdQueue ' usage
  </code></pre>
  
  <p>Any help appreciated.
  Thanks.</p>
  
  <p><strong>edit:</strong></p>
  
  <p>thanks for all the answers, but tcarvin answer was what I was looking for.
  The queue is private from my singleton Comms object that queues new messages to be sent (exposed by a Send method), the queue is consumed in a worker thread within this object one message at a time and the only code I have inside the locks are one call to Enqueue and Dequeue.</p>