title: Deadlocks and Livelocks issues using @synchronized directive in objective c
body: <p>from the apple's <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/ThreadSafety/ThreadSafety.html" rel="nofollow">"Threading Programming Guide"</a> I've read that "The best way to avoid both deadlock and livelock situations is to take only one lock at a time". If I prefer to use the @synchronized directive in my code, this means that I should do something like this:</p>
  
  <blockquote>
    <p>@synchronized(aObj) {</p>
  
  <pre><code>@synchronized(bObj) {
  
      // do sth with the aObj and bObj here     
  } 
  </code></pre>
    
    <p>}</p>
  </blockquote>
  
  <p>instead of this:</p>
  
  <blockquote>
    <p>@synchronized(aObj, bObj) {</p>
  
  <pre><code> // do sth with the aObj and bObj here
  </code></pre>
    
    <p>}</p>
  </blockquote>
  
  <p>?? if not, what it means by "One lock at a time?". Thank you...</p>