Order of operations

Sometimes I can be such a buffoon. When programming with threads, one must be sure to lock and unlock in the correct order. Also, one must be sure not to do things explicitly marked as no-nos while in a “critical section.”
I just lost two hours to this, so I felt the need to whine.