title: Java CountDownLatch waits for the timeout value when the thread.run() counting down the latch gets an exception
body: <p>I am using a <code>CountDownLatch</code> to handle two Java threads. My class structure is as follows: </p>
  
  <p>MainClass.java<br>
  ThreadOne.java<br>
  ThreadTwo.java<br></p>
  
  <p>MainClass: </p>
  
  <pre><code>CountDownLatch latch = new CountDownLatch(2);           
  Thread thread = new Thread(new ThreadOne(latch));
  thread.start();
  
  Thread thread1 = new Thread(new ThreadTwo(latch));
  thread1.start();        
  
  latch.await(20, TimeUnit.SECONDS);
  </code></pre>
  
  <p>Main class waits until other two threads complete their work. As soon as they complete their work it does not wait until its timeout value (20 secs). My problem is if any of the threads get destroyed or corrupted then the <code>CountDownLatch</code> waits for its timeout value. Is there any way to ignore that interrupted thread and move forward without waiting 20 seconds? </p>