private static boolean checkConditionMetForAll ( CountDownLatch latch , int expected , AtomicInteger actual , long amount , TimeUnit timeUnit ) { try { if ( latch . await ( amount , timeUnit ) ) { return actual . intValue ( ) == expected ; } return false ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; return false ; } }
Waits until the latch reaches to zero and then checks if the expected result