title: Given two Java threads, stop one thread when one of them finishes
body: <p>I'm looking for a clean design/solution for this problem: I have two threads, that may run as long as the user wants to, but eventually stop when the user issues the stop command. However if one of the threads ends abruptly (eg. because of a runtime exception) I want to stop the other thread.</p>
  
  <p>Now both threads execute a <code>Runnable</code> (so when I say 'stop a thread' what I mean is that I call a stop() method on the <code>Runnable</code> instance), what I'm thinking is to avoid using threads (Thread class) and use the <code>CompletionService</code> interface and then submit both Runnables to an instance of this service.</p>
  
  <p>With this I would use the CompletionService's method <code>take()</code>, when this method returns I would stop both Runnables since I know that at least one of them already finished. Now, this works, but if possible I would like to know of a simpler/better solution for my case.</p>
  
  <p>Also, what is a good solution when we have <code>n</code> threads and as soon as one of them finishes to stop execution of all the others ? </p>
  
  <p>Thanks in advance.</p>