title: Best practice for interrupting threads that take longer than a threshold
body: <p>I am using the Java ExecutorService framework to submit callable tasks for execution. 
  These tasks communicate with a web service and a web service timeout of 5 mins is applied.
  However I've seen that in some cases the timeout is being ignored and thread 'hangs' on an API call - hence, I want to cancel all the tasks that take longer than say, 5 mins.</p>
  
  <p>Currently, I have a list of futures and I iterate through them and call future.get until all tasks are complete. Now, I've seen that the future.get overloaded method takes a timeout and throws a timeout when the task doesnt complete in that window. So I thought of an approach where I do a future.get() with timeout and in case of TimeoutException I do a future.cancel(true) to make sure that this task is interrupted. </p>
  
  <p>My main questions<br>
   1. Is the get with a timeout the best way to solve this issue?<br>
   2. Is there the possibility that I'm waiting with the get call on a task that hasnt yet been placed on the thread pool(isnt an active worker). In that case I may be terminating a thread that, when it starts may actually complete within the required time limit?  </p>
  
  <p>Any suggestions would be deeply appreciated. </p>