title: how to guarantee no deadlock
body: <p>I was stuck at one question in an interview. </p>
  
  <p>Given two threads, and each one has a lock, how to guarantee no deadlock.</p>
  
  <p>My knowledge is that it is not easy to avoid deadlock, that's why I got stuck. Can anybody give a hint.</p>
  
  <p>Thanks!</p>