Remedy the deadlock by ensuring ordering operations of lock acquisition.