title: Proper way to try-catch a semaphore
body: <p>What is the proper way to wrap semaphore actions in a try-catch block?  What happens if the acquire action is interrupted after it has acquired some number, but not all, of the permits requested?  How do you know how many to release again?  Should the release go in a "finally" block, but then aren't you possibly releasing permits you didn't get if the action was interrupted?</p>
  
  <pre><code>try {
      lock.acquire(permits);
  
      //Do some things that require synchronization
  
      //Make sure to release all of the permits again!
      lock.release(permits);
  } catch (InterruptedException e) {
      log.error("Interrupted!");
  }
  </code></pre>