private boolean removeTokenIfUnused(Object name) {
    synchronized (tokens) {
      if (destroyed) {
        getStats().incFreeResourcesFailed();
        return false;
      }
      DLockToken token = tokens.get(name);
      if (token != null) {
        synchronized (token) {
          if (!token.isBeingUsed()) {
            if (logger.isTraceEnabled(LogMarker.DLS_VERBOSE)) {
              logger.trace(LogMarker.DLS_VERBOSE, "Freeing {} in {}", token, this);
            }
            removeTokenFromMap(name);
            token.destroy();
            getStats().incTokens(-1);
            getStats().incFreeResourcesCompleted();
            return true;
          }
        }
      }
    }
    getStats().incFreeResourcesFailed();
    return false;
  }
Attempt to destroy and remove lock token. Synchronizes on tokens map and the lock token.

@param name the name of the lock token
@return true if token has been destroyed and removed
geode-core/src/main/java/org/apache/geode/distributed/internal/locks/DLockService.java