Code example for CountDownLatch

Methods: await, getCount

0
    strategy.load(cache);
  } 
 
  private void checkSync() { 
    if (strategy.getLoadPolicy() == LoadPolicy.SYNC
        || latch.getCount() == 0) {
      return; 
    } 
 
    if (strategy.getLoadPolicy() == LoadPolicy.ASYNC_EXCEPTION) {
      throw new RuntimeException(
                                 "Tried to access preferences before load completed"); 
    } 
 
    try { 
      latch.await();
    } 
    catch (InterruptedException e) {
      // presume life is OK and move along 
    } 
  }