I was stuck at one question in an interview. 

Given two threads, and each one has a lock, how to guarantee no deadlock.

My knowledge is that it is not easy to avoid deadlock, that's why I got stuck. Can anybody give a hint.

Thanks!