public void lock(int id) {
      lock.lock();
      try {
        while (lockedIds.contains(id)) {
          unlockCondition.awaitUninterruptibly();
        }
        lockedIds.add(id);
      }
      finally {
        lock.unlock();
      }
    }
public void lock(int id)