本文整理了Java中java.util.concurrent.ConcurrentHashMap.<init>()
方法的一些代码示例,展示了ConcurrentHashMap.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConcurrentHashMap.<init>()
方法的具体详情如下:
包路径:java.util.concurrent.ConcurrentHashMap
类名称:ConcurrentHashMap
方法名:<init>
[英]Creates a new, empty map with a default initial capacity (16), load factor (0.75) and concurrencyLevel (16).
[中]创建具有默认初始容量(16)、负载系数(0.75)和并发级别(16)的新空映射。
代码示例来源:origin: apache/incubator-dubbo
@Override
public void put(String componentName, String key, Object value) {
Map<String, Object> componentData = data.get(componentName);
if (null == componentData) {
data.putIfAbsent(componentName, new ConcurrentHashMap<String, Object>());
componentData = data.get(componentName);
}
componentData.put(key, value);
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Get the snapshot map for the given log channel ID. If no map is available, one is created (and stored).
*
* @param logChannelId
* The log channel to use.
* @return an existing or a new metrics snapshot map.
*/
public Map<String, MetricsSnapshotInterface> getSnapshotMap( String logChannelId ) {
Map<String, MetricsSnapshotInterface> map = snapshotMaps.get( logChannelId );
if ( map == null ) {
map = new ConcurrentHashMap<String, MetricsSnapshotInterface>();
snapshotMaps.put( logChannelId, map );
}
return map;
}
代码示例来源:origin: mpusher/mpush
@Override
public <T> T hget(String key, String field, Class<T> tClass) {
Object obj = ((Map) cache.computeIfAbsent(key, k -> new ConcurrentHashMap<>())).get(field);
if (obj == null) return null;
return Jsons.fromJson(obj.toString(), tClass);
}
代码示例来源:origin: spring-projects/spring-framework
throws MissingResourceException {
Map<String, Map<Locale, MessageFormat>> codeMap = this.cachedBundleMessageFormats.get(bundle);
Map<Locale, MessageFormat> localeMap = null;
if (codeMap != null) {
localeMap = codeMap.get(code);
if (localeMap != null) {
MessageFormat result = localeMap.get(locale);
if (result != null) {
return result;
if (msg != null) {
if (codeMap == null) {
codeMap = new ConcurrentHashMap<>();
Map<String, Map<Locale, MessageFormat>> existing =
this.cachedBundleMessageFormats.putIfAbsent(bundle, codeMap);
localeMap = new ConcurrentHashMap<>();
Map<Locale, MessageFormat> existing = codeMap.putIfAbsent(code, localeMap);
if (existing != null) {
localeMap.put(locale, result);
return result;
代码示例来源:origin: apache/incubator-dubbo
@Override
public void put(String componentName, String key, Object value) {
Map<String, Object> componentData = data.get(componentName);
if (null == componentData) {
data.putIfAbsent(componentName, new ConcurrentHashMap<String, Object>());
componentData = data.get(componentName);
}
componentData.put(key, value);
}
代码示例来源:origin: mpusher/mpush
@Override
public long hincrBy(String key, String field, long value) {
Map fields = ((Map) cache.computeIfAbsent(key, k -> new ConcurrentHashMap<>()));
Number num = (Number) fields.get(field);
long result = num.longValue() + 1;
fields.put(field, result);
executor.execute(this::writeToFile);
return result;
}
代码示例来源:origin: spring-projects/spring-framework
Map<Locale, ResourceBundle> localeMap = this.cachedResourceBundles.get(basename);
if (localeMap != null) {
ResourceBundle bundle = localeMap.get(locale);
if (bundle != null) {
return bundle;
ResourceBundle bundle = doGetBundle(basename, locale);
if (localeMap == null) {
localeMap = new ConcurrentHashMap<>();
Map<Locale, ResourceBundle> existing = this.cachedResourceBundles.putIfAbsent(basename, localeMap);
if (existing != null) {
localeMap.put(locale, bundle);
return bundle;
代码示例来源:origin: neo4j/neo4j
ServerExtender( PluginPointFactory pluginPointFactory )
{
this.pluginPointFactory = pluginPointFactory;
targetToPluginMap.put( Node.class, new ConcurrentHashMap<>() );
targetToPluginMap.put( Relationship.class, new ConcurrentHashMap<>() );
targetToPluginMap.put( GraphDatabaseService.class, new ConcurrentHashMap<>() );
}
代码示例来源:origin: spring-projects/spring-framework
private static Map<String, Object> mergeAttributes(ServerRequest request,
Map<String, String> pathVariables, PathPattern pattern) {
Map<String, Object> result = new ConcurrentHashMap<>(request.attributes());
result.put(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE,
mergePathVariables(request.pathVariables(), pathVariables));
pattern = mergePatterns(
(PathPattern) request.attributes().get(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE),
pattern);
result.put(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE, pattern);
return result;
}
代码示例来源:origin: apache/flink
private void putIntoUpdatingResource(String key, String[] value) {
Map<String, String[]> localUR = updatingResource;
if (localUR == null) {
synchronized (this) {
localUR = updatingResource;
if (localUR == null) {
updatingResource = localUR = new ConcurrentHashMap<>(8);
}
}
}
localUR.put(key, value);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Nullable
public MessageFormat getMessageFormat(String code, Locale locale) {
if (this.properties == null) {
return null;
}
Map<Locale, MessageFormat> localeMap = this.cachedMessageFormats.get(code);
if (localeMap != null) {
MessageFormat result = localeMap.get(locale);
if (result != null) {
return result;
}
}
String msg = this.properties.getProperty(code);
if (msg != null) {
if (localeMap == null) {
localeMap = new ConcurrentHashMap<>();
Map<Locale, MessageFormat> existing = this.cachedMessageFormats.putIfAbsent(code, localeMap);
if (existing != null) {
localeMap = existing;
}
}
MessageFormat result = createMessageFormat(msg, locale);
localeMap.put(locale, result);
return result;
}
return null;
}
}
代码示例来源:origin: apache/incubator-druid
public static Map<String, Object> makeResponseContextForQuery()
{
final Map<String, Object> responseContext = new ConcurrentHashMap<>();
responseContext.put(
DirectDruidClient.QUERY_TOTAL_BYTES_GATHERED,
new AtomicLong()
);
return responseContext;
}
代码示例来源:origin: spring-projects/spring-framework
@Nullable
private String getBeanNameByType(WebApplicationContext wac, Class<?> endpointClass) {
String wacId = wac.getId();
Map<Class<?>, String> beanNamesByType = cache.get(wacId);
if (beanNamesByType == null) {
beanNamesByType = new ConcurrentHashMap<>();
cache.put(wacId, beanNamesByType);
}
if (!beanNamesByType.containsKey(endpointClass)) {
String[] names = wac.getBeanNamesForType(endpointClass);
if (names.length == 1) {
beanNamesByType.put(endpointClass, names[0]);
}
else {
beanNamesByType.put(endpointClass, NO_VALUE);
if (names.length > 1) {
throw new IllegalStateException("Found multiple @ServerEndpoint's of type [" +
endpointClass.getName() + "]: bean names " + Arrays.asList(names));
}
}
}
String beanName = beanNamesByType.get(endpointClass);
return (NO_VALUE.equals(beanName) ? null : beanName);
}
代码示例来源:origin: hibernate/hibernate-orm
private static Map<EntityMode,Class<? extends ComponentTuplizer>> buildBaseMapping() {
Map<EntityMode,Class<? extends ComponentTuplizer>> map = new ConcurrentHashMap<EntityMode,Class<? extends ComponentTuplizer>>();
map.put( EntityMode.POJO, PojoComponentTuplizer.class );
map.put( EntityMode.MAP, DynamicMapComponentTuplizer.class );
return map;
}
}
代码示例来源:origin: Qihoo360/XLearning
public Map<XLearningContainerId, ConcurrentHashMap<String, List<Double>>> getContainersCpuStatistics(){
Map<XLearningContainerId, ConcurrentHashMap<String, List<Double>>> cpuStatistics = new ConcurrentHashMap<>();
for(XLearningContainerId id: this.containersCpuStatistics.keySet()){
Map<String, ContainerMetricsStatisticsTuple> statisticsTuple = this.containersCpuStatistics.get(id);
ConcurrentHashMap<String, List<Double>> statisticsValue = new ConcurrentHashMap<>();
for (String str: statisticsTuple.keySet()){
statisticsValue.put(str, statisticsTuple.get(str).getStatisticsInfo());
}
cpuStatistics.put(id, statisticsValue);
}
return cpuStatistics;
}
代码示例来源:origin: hibernate/hibernate-orm
private static Map<EntityMode,Class<? extends EntityTuplizer>> buildBaseMapping() {
Map<EntityMode,Class<? extends EntityTuplizer>> map = new ConcurrentHashMap<EntityMode,Class<? extends EntityTuplizer>>();
map.put( EntityMode.POJO, PojoEntityTuplizer.class );
map.put( EntityMode.MAP, DynamicMapEntityTuplizer.class );
return map;
}
}
代码示例来源:origin: apache/flink
protected synchronized Properties getProps() {
if (properties == null) {
properties = new Properties();
Map<String, String[]> backup =
new ConcurrentHashMap<String, String[]>(updatingResource);
loadResources(properties, resources, quietmode);
if (overlay != null) {
properties.putAll(overlay);
for (Entry<Object,Object> item: overlay.entrySet()) {
String key = (String)item.getKey();
String[] source = backup.get(key);
if(source != null) {
updatingResource.put(key, source);
}
}
}
}
return properties;
}
代码示例来源:origin: alipay/sofa-rpc
/**
* Sets parameter.
*
* @param key the key
* @param value the value
*/
public MethodConfig setParameter(String key, String value) {
if (parameters == null) {
parameters = new ConcurrentHashMap<String, String>();
}
parameters.put(key, value);
return this;
}
代码示例来源:origin: stanfordnlp/CoreNLP
@Override
public V put(Iterable<K> key, V value) {
if (value == null) throw new IllegalArgumentException("Value cannot be null");
TrieMap<K, V> curTrie = this;
// go through each element
for(K element:key){
if (curTrie.children == null) {
curTrie.children = new ConcurrentHashMap<>();//Generics.newConcurrentHashMap();
}
TrieMap<K, V> parent = curTrie;
curTrie = curTrie.children.get(element);
if(curTrie == null){
parent.children.put(element, curTrie = new TrieMap<>());
}
}
V oldValue = curTrie.value;
curTrie.value = value;
return oldValue;
}
代码示例来源:origin: alipay/sofa-rpc
/**
* Sets parameter.
*
* @param key the key
* @param value the value
*/
public MethodConfig setParameter(String key, String value) {
if (parameters == null) {
parameters = new ConcurrentHashMap<String, String>();
}
parameters.put(key, value);
return this;
}
内容来源于网络,如有侵权,请联系作者删除!