java.util.concurrent.ConcurrentHashMap.forEachKey()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(225)

本文整理了Java中java.util.concurrent.ConcurrentHashMap.forEachKey()方法的一些代码示例,展示了ConcurrentHashMap.forEachKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConcurrentHashMap.forEachKey()方法的具体详情如下:
包路径:java.util.concurrent.ConcurrentHashMap
类名称:ConcurrentHashMap
方法名:forEachKey

ConcurrentHashMap.forEachKey介绍

暂无

代码示例

代码示例来源:origin: oracle/helidon

void evict() {
  cacheMap.forEachKey(evictParallelismThreshold, key -> cacheMap.compute(key, (key1, cacheRecord) -> {
    if ((null == cacheRecord) || evictor.apply(cacheRecord.getKey(), cacheRecord.getValue())) {
      return null;
    } else {
      if (cacheRecord.isValid(cacheTimoutNanos)) {
        return cacheRecord;
      } else {
        return null;
      }
    }
  }));
}

代码示例来源:origin: zalando/tokens

protected String getAvailableTokenIds() {
  if(availableTokenIds == null) {
    List<String> tokenIds = new ArrayList<String>();
    accessTokens.forEachKey(Long.MAX_VALUE, key -> {
      tokenIds.add(key.toString());
    });
    availableTokenIds = tokenIds.isEmpty() ? "[]" : tokenIds.toString();
  }
  return availableTokenIds;
}

代码示例来源:origin: org.zalando.stups/tokens

protected String getAvailableTokenIds() {
  if(availableTokenIds == null) {
    List<String> tokenIds = new ArrayList<String>();
    accessTokens.forEachKey(Long.MAX_VALUE, key -> {
      tokenIds.add(key.toString());
    });
    availableTokenIds = tokenIds.isEmpty() ? "[]" : tokenIds.toString();
  }
  return availableTokenIds;
}

代码示例来源:origin: gauravrmazra/gauravbytes

private static void concurrentMapNewFeatures() {
    ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
    map.put("One", "One");
    map.put("One1", "One");
    map.put("One11", "One");
    map.put("One111", "One");
    map.put("One1111", "One");

    map.forEachKey(2, k -> k.length(), System.out::println);
  }
}

代码示例来源:origin: io.helidon.security.providers/helidon-security-providers-common

void evict() {
  cacheMap.forEachKey(evictParallelismThreshold, key -> cacheMap.compute(key, (key1, cacheRecord) -> {
    if ((null == cacheRecord) || evictor.apply(cacheRecord.getKey(), cacheRecord.getValue())) {
      return null;
    } else {
      if (cacheRecord.isValid(cacheTimoutNanos)) {
        return cacheRecord;
      } else {
        return null;
      }
    }
  }));
}

代码示例来源:origin: io.helidon.security/helidon-security-providers-common

void evict() {
  cacheMap.forEachKey(evictParallelismThreshold, key -> cacheMap.compute(key, (key1, cacheRecord) -> {
    if ((null == cacheRecord) || evictor.apply(cacheRecord.getKey(), cacheRecord.getValue())) {
      return null;
    } else {
      if (cacheRecord.isValid(cacheTimoutNanos)) {
        return cacheRecord;
      } else {
        return null;
      }
    }
  }));
}

代码示例来源:origin: com.qwazr/qwazr-store

final SortedSet<UUID> getWalkThreads() {
  return rwl.read(() -> {
    final SortedSet<UUID> keys = Collections.synchronizedSortedSet(new TreeSet<>());
    walkthreads.forEachKey(0, keys::add);
    return keys;
  });
}

代码示例来源:origin: hank-whu/turbo-rpc

@Override
public void close() throws IOException {
  appMap.forEachKey(4, app -> {
    try {
      app.close();
    } catch (IOException e) {
      if (logger.isWarnEnabled()) {
        logger.warn("client close error", e);
      }
    }
  });
  EventLoopGroupHolder.release(eventLoopGroup);
  appMap.clear();
  remoteServiceFactory.close();
}

代码示例来源:origin: com.turbo-rpc/turbo-rpc

@Override
public void close() throws IOException {
  appMap.forEachKey(4, app -> {
    try {
      app.close();
    } catch (IOException e) {
      if (logger.isWarnEnabled()) {
        logger.warn("client close error", e);
      }
    }
  });
  EventLoopGroupHolder.release(eventLoopGroup);
  appMap.clear();
  remoteServiceFactory.close();
}

相关文章