Java ConcurrentHashMap putIfAbsent(ConcurrentHashMap col, K key, V val)

Here you can find the source of putIfAbsent(ConcurrentHashMap col, K key, V val)

Description

put If Absent

License

Open Source License

Parameter

Parameter Description
col a parameter
key a parameter
val a parameter

Declaration

public static <K, V> V putIfAbsent(ConcurrentHashMap<K, V> col, K key, V val) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.concurrent.ConcurrentHashMap;

public class Main {
    /***//from  ww  w  .  ja  va 2 s .  c  o m
     * 
     * @param col
     * @param key
     * @param val
     * @return
     */
    public static <K, V> V putIfAbsent(ConcurrentHashMap<K, V> col, K key, V val) {
        if (col.containsKey(key) == false) {
            col.put(key, val);
        }
        return col.get(key);
    }
}

Related

  1. getDoubleSafe(ConcurrentHashMap map, String key)
  2. getMapSafe( ConcurrentHashMap> map, String key)
  3. max(ConcurrentHashMap map)
  4. ParseKeyValString(String keyValString, ConcurrentHashMap map)
  5. parseMap(String config, ConcurrentHashMap map)
  6. setFieldValue(Object value, ConcurrentHashMap fieldHolder, String name, String desc)