title: How to Interrupt Java Semaphore.tryAcquire Function
body: <p>I've a function which calls <code>Semaphore.tryAcquire(timeout, timeunit)</code> function. Now I want to interrupt this tryAcquire functions so that the caller function will throw some exception. My code idea is as below:</p>
  
  <pre><code>public void run() throw InterruptedException{
      semaphore.tryAcquire(timeout, timeunit);
  }
  
  public void interrupt(){
     // interrupt my run() function execution so that run() will throw InterruptedException
  }
  </code></pre>
  
  <p>Any possible way to do that?</p>