We discussed the solutions to the deadlock problem. Points to take away from the discussion:
thread_lock(global);
thread_lock(locks[id1]);
thread_lock(locks[id2]);
thread_unlock(global);
<transfer money>
thread_lock(global);
thread_unlock(locks[id1]);
thread_unlock(locks[id2]);
thread_unlock(global);

Consider the following example
Thread 1
1. thread_lock(global);
2. thread_lock(locks[1]);
3. thread_lock(locks[2]);
4. thread_unlock(global);
Thread 2
5. thread_lock(global);
6. thread_lock(locks[3]);
7. thread_lock(locks[2]);  // Thread 2 will block here
... Thread 2 is still holding the "global" lock.
Thread 1
cannot release locks[2]
because it cannot acquire the
"global" lock
thread_lock(global);
thread_lock(locks[id1]);
thread_lock(locks[id2]);
thread_unlock(global);
<transfer money>
thread_lock(global);
thread_unlock(locks[id1]);
thread_unlock(locks[id2]);
thread_unlock(global);

This serializes all requests: transfers between two un-related accounts cannot happen concurrently. BAD.