implement deadlock detection