title: CountDownLatch InterruptedException
body: <p>I am using the <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/CountDownLatch.html" rel="noreferrer">CountDownLatch</a> to synchronize an initialization process between two threads and I was wondering about the proper handling of the <a href="http://java.sun.com/javase/6/docs/api/java/lang/InterruptedException.html" rel="noreferrer">InterruptedException</a> that it might throw.</p>
  
  <p>the code i initially wrote was this:</p>
  
  <pre><code>    private CountDownLatch initWaitHandle = new CountDownLatch(1);
      /**
       * This method will block until the thread has fully initialized, this should only be called from different threads  Ensure that the thread has started before this is called.
       */
      public void ensureInitialized()
      {
          assert this.isAlive() : "The thread should be started before calling this method.";
          assert Thread.currentThread() != this, "This should be called from a different thread (potential deadlock)";
          while(true)
          {
              try
              {
                  //we wait until the updater thread initializes the cache
                  //that way we know 
                  initWaitHandle.await();
                  break;//if we get here the latch is zero and we are done
              } 
              catch (InterruptedException e)
              {
                  LOG.warn("Thread interrupted", e);
              }
          }
      }
  </code></pre>
  
  <p>Does this pattern make sense?  Basically is it a good idea to ignore the <a href="http://java.sun.com/javase/6/docs/api/java/lang/InterruptedException.html" rel="noreferrer">InterruptedException</a> just keep waiting until it succeeds.  I guess I just don't understand the situations under which this would get interrupted so I don't know if I should be handling them differently.</p>
  
  <p>Why would an InterruptedException get thrown here, what is the best practice for handling it?</p>