public static void waitUntilBlock(int threadCount) {
      Semaphore semaphore = _semaphore;

      if (semaphore != null) {
        while (semaphore.getQueueLength() < threadCount) ;
      }
    }
 private void logState() {
   logger.debug(
       "Available permits: {} thread queue: {} state: {} threshold: {}",
       new Object[] {
         lock.availablePermits(), lock.getQueueLength(), counter.get(), getThreshold()
       });
 }