title: Lock tree algorithm deadlock detection
body: <p>I've been working on some examples of the Lock tree deadlock detection algorithm and been unable to figure out how a deadlock occurs in this particular situation:</p>
  
  <pre><code>Thread 1:           Thread 2:
  
  lock(A)             lock(E)
  lock(C)             lock(D)
  unlock(C)           unlock(D)
  lock(B)             unlock(A)
  lock(D)             lock(A)
  lock(E)             lock(C)
  unlock(E)           unlock(C)
  unlock(D)           unlock(A)
  unlock(B)
  unlock(A)
  </code></pre>
  
  <p>From my understanding the Lock tree should look something like this:</p>
  
  <pre><code>  T1:          T2:
                /  \
    A          E    A
   / \         |    |
  C   B        D    C
      |
      D
      | 
      E
  </code></pre>
  
  <p>Could it be that the deadlock occurs at nodes T1: D - E  and  T2: E - D, because the threads take those locks in opposite order?</p>
  
  <p>How could I suggest insertion of one lock and one unlock statement to remove the deadlock?</p>