title: ReentrantLock with nested tryLock with different timeouts, what will be the actual timeout?
body: <p>I am trying to create an unfair buffer with two calls</p>
  
  <ol>
  <li>Add value to the buffer</li>
  <li>Empty the buffer</li>
  </ol>
  
  <p>Threads that empty the queue should have <strong>higher priority</strong> them threads that add to the queue.</p>
  
  <p>In case the buffer is full I call the empty method internally to allow the queue to empty.</p>
  
  <p>The basic idea is that the locks on add buffer are limited to <strong>addTimeout</strong> and the locks for empty is <strong>emptyAddRatio * addTimeout</strong>  so add will have higher priority (The assumption is that I have more additions then empty).</p>
  
  <pre><code>public class EmptyPriorityBuffer {
  private ReentrantLock lock = new ReentrantLock(true);
  private long addTimeout = 10;
  private long emptyAddRatio = 5;
  private int maxSize = 1000;
  private LinkedBlockingDeque&lt;Object&gt; buffer = new LinkedBlockingDeque&lt;&gt;(maxSize);
  
  public List&lt;Object&gt; empty() {
      try {
          lock.tryLock(addTimeout * emptyAddRatio, TimeUnit.MILLISECONDS);
          ArrayList&lt;Object&gt; result = new ArrayList&lt;&gt;();
          buffer.drainTo(result);
          return result;
      } catch (InterruptedException e) {
          e.printStackTrace();
      } finally {
          lock.unlock();
      }
      return Collections.emptyList();
  }
  
  public void add(Object object) {
      try {
          lock.tryLock(addTimeout, TimeUnit.MILLISECONDS);
          if (!buffer.offer(object)) {
              empty();
              buffer.offer(object);
          }
      } catch (InterruptedException e) {
          e.printStackTrace();
      } finally {
          lock.unlock();
      }
  }
  </code></pre>
  
  <p><strong>My question:</strong> 
  What will happen in the case where the buffer is full.<br>
  The current thread acquired to lock with addtimeout, now it asks for a nested lock with <strong>emptyAddRatio * addTimeout</strong> witch is larger then <strong>addTimeout</strong>.<br>
  Will the thread be interrupted after <strong>emptyAddRatio * addTimeout</strong>  or <strong>addTimeout</strong>?</p>