public void waitForActiveLocks() throws InterruptedException {
  long now=-1;
  while (true) {
    boolean nochange;
    Set<WeakLockReference> before;
synchronized (activeLocks) {
      if (activeLocks.isEmpty())       return;
      before=new HashSet<WeakLockReference>(activeLocks);
      if (now < 0) {
        now=System.currentTimeMillis();
      }
      activeLocks.wait(waitToCollect);
      if (activeLocks.isEmpty())       return;
      nochange=before.equals(activeLocks);
    }
    if (nochange && System.currentTimeMillis() - now >= waitToCollect / 2) {
      releaseAbandoned();
      now=-1;
    }
  }
}

public void waitForActiveLocks ( ) throws InterruptedException { long now = - 1 ; while ( true ) { boolean nochange ; Set < WeakLockReference > before ; synchronized ( activeLocks ) { if ( activeLocks . isEmpty ( ) ) return ; before = new HashSet < WeakLockReference > ( activeLocks ) ; if ( now < 0 ) { now = System . currentTimeMillis ( ) ; } activeLocks . wait ( waitToCollect ) ; if ( activeLocks . isEmpty ( ) ) return ; nochange = before . equals ( activeLocks ) ; } if ( nochange && System . currentTimeMillis ( ) - now >= waitToCollect / 2 ) { releaseAbandoned ( ) ; now = - 1 ; } } }
blocks current thread until the number of active locks has reached zero .
