title: ReentrantReadWriteLock (java) - nest write lock inside read lock
body: <p>In the below code snippet, would it lead to a deadlock?</p>
  
  <pre><code>public class TestLocks {
  
  ReadWriteLock lock = new ReentrantReadWriteLock();
  public void add() {
      lock.readLock().lock();
      //code.....
  
      lock.writeLock().lock();
      //code
      lock.writeLock().unlock();
  
      //code....
      l.readLock().unlock();
  }
  </code></pre>
  
  <p>What I'm doing above is using ReentrantReadWriteLock, lock 'lock' for reading and inside it again try to acquire lock for writing (before releasing the readLock). This might never be done in production but was curious to know if the above code would lead to a deadLock?</p>