title: ReadWriteLock. Understanding upgrading from readLock to writeLock
body: <p>Consider this <code>JDK</code> standard interface:</p>
  
  <pre><code>public interface ReadWriteLock{
      public Lock readLock();
      public Lock writeLock();
  }
  </code></pre>
  
  <p>B. Goetz in Java Concurrency in practice mentioned upgrading from readLock to writeLock is deadlock-prone.</p>
  
  <blockquote>
    <p>If two readers simultaneously attempt to upgrade to a write lock,
    neither will realese the read lock.</p>
  </blockquote>
  
  <p>The thing that's confused me is that it was <strong><em>two</em></strong> readers attempting to upgrade. But even one reader is enough, isn't? If a reader tries to upgrade it's not released the read lock yet. Trying to acquire the write lock with the read lock held is deadlocky.</p>
  
  <p>So judging by that I think it's even theoretically nonsensical to provide the upgrade operation. Or maybe an implementation can take care of that?</p>