question: public void waitForState ( final String collection , long wait , TimeUnit unit , CollectionStatePredicate predicate ) throws InterruptedException , TimeoutException { final CountDownLatch latch = new CountDownLatch ( 1 ) ; CollectionStateWatcher watcher = null ; registerCollectionStateWatcher ( collection , watcher ) ; try { if ( ! latch . await ( wait , unit ) ) throw new TimeoutException ( ) ; } finally { removeCollectionStateWatcher ( collection , watcher ) ; } }
target:  Block until a CollectionStatePredicate returns true, or the wait times out Note that the predicate may be called again even after it has returned true, so implementors should avoid changing state within the predicate call itself.