title: How to stop a URL connection upon thread interruption Java
body: <p>I have a multithreaded program that visits URLs. The threads are run through an executor service, and when the user chooses to quit through the GUI, the program attempts to interrupt the threads by calling <code>executor.shutdownNow()</code>. However, it takes a very long time for the program to shut down because many of the threads are blocked in a <code>url.openStream()</code> call, and since this does not throw <code>InterruptedException</code>, so far I've been forced to just check before and after the call for <code>Thread.currentThread().isInterrupted()</code>.  </p>
  
  <p>I'm wondering if there is a better way to interrupt a URL connection upon thread interruption? Otherwise, what would be the best approach to let the program shutdown as quickly as possible?  </p>
  
  <p>Note that I would prefer not to set a timeout on the connections because I would like all URLs to be visited while the program is still running.</p>