HashMap线程不安全,ConcurrentHashMap是线程安全的。但是如果val是空值

public class TestCurrenHaseMap {

    public static void main(String[] args) {

        String key = "java";
        Map<String,Object> map = new ConcurrentHashMap<>();
        map.put("1","2");
        map.put(key,null);

        System.out.println(JSON.toJSONString(map));
    }
}


打印的结果会报空指针,而如果new 的 时候用HashMap那么就不会有这个问题