public static HashSet<Long> getOrInitHashMapCacheValue(Long mId){
// HashSet<Long> set = getHashMapRefCache().get(mId);
// if(set == null){
// set = getHashSet();
// getHashMapRefCache().put(mId, set);
// }
// return set;
HashSet<Long> set = getHashMapRefCache().get(mId);
if(set == null){
set = getHashSet();
HashSet<Long> ret = getHashMapRefCache().putIfAbsent(mId, set);
if(ret!=null){
set = ret;
}
}
return set;
}

putIfAbsent的更多相关文章

  1. 深入理解ConcurrentMap.putIfAbsent(key,value) 用法

    转自:http://blog.csdn.net/exceptional_derek/article/details/40384659 先看一段代码: public class Locale { pri ...

  2. put与putIfAbsent区别

    put与putIfAbsent区别: put在放入数据时,如果放入数据的key已经存在与Map中,最后放入的数据会覆盖之前存在的数据, 而putIfAbsent在放入数据时,如果存在重复的key,那么 ...

  3. ConcurrentHashMap中的putIfAbsent方法的使用以及返回值的含义

    public V putIfAbsent(@NotNull K key, @NotNull V value) putIfAbsent方法主要是在向ConcurrentHashMap中添加键—值对的时候 ...

  4. map的put和putIfAbsent使用

    源码中传入key和value,根据key获取看是否存在value,如果value==null,然后调用put方法把传入的key和value  put进map,返回根据key获取的老value 意思就是 ...

  5. ConcurrentHashMap 中putIfAbsent 和put的区别

    putIfAbsent 源代码 public V putIfAbsent(K key, V value) { Segment<K,V> s; if (value == null) thro ...

  6. ConcurrentMap.putIfAbsent(key,value) 用法讨论

    ConcurrentMap.putIfAbsent(key,value) 用法讨论 http://wxl24life.iteye.com/blog/1746794

  7. ConcurrentHashMap的putIfAbsent

    这个方法在key不存在的时候加入一个值,如果key存在就不放入,等价: if (!map.containsKey(key)) return map.put(key, value); else retu ...

  8. HashMap中的putIfAbsent使用示例

    原文:https://blog.csdn.net/k3108001263/article/details/83720445 如果不存在key,则添加到HashMap中,跟put方法相似 如果存在key ...

  9. 多线程爬坑之路-学习多线程需要来了解哪些东西?(concurrent并发包的数据结构和线程池,Locks锁,Atomic原子类)

    前言:刚学习了一段机器学习,最近需要重构一个java项目,又赶过来看java.大多是线程代码,没办法,那时候总觉得多线程是个很难的部分很少用到,所以一直没下决定去啃,那些年留下的坑,总是得自己跳进去填 ...

随机推荐

  1. Python之旅:流程控制

    流程控制之if...else 每条if语句的核心都是一个值为True或False的表达式,这种表达式被称为条件测试. Python条件语句是通过一条或多条语句的执行结果(True或者False)来决定 ...

  2. cocoaPods安装、更新第三方库

    pod install 换成 pod install --verbose --no-repo-update pod update 换成 pod update --verbose --no-repo-u ...

  3. python 中__getitem__ 和 __iter__ 的区别

    # -*- coding: utf-8 -*- class Library(object): def __init__(self): self.books = { 'title' : 'a', 'ti ...

  4. python---方法解析顺序MRO(Method Resolution Order)<以及解决类中super方法>

    MRO了解: 对于支持继承的编程语言来说,其方法(属性)可能定义在当前类,也可能来自于基类,所以在方法调用时就需要对当前类和基类进行搜索以确定方法所在的位置.而搜索的顺序就是所谓的「方法解析顺序」(M ...

  5. MongoDB 数据迁移和同步

    MongoDB 数据迁移和同步 MongoDB的数据同步 复制 mongodb的复制至少需要两个实例.其中一个是主节点master,负责处理客户端请求,其余的都是slave,负责从master上复制数 ...

  6. Android 利用 gson 将 json 转成 对象object 集合list

    1.build.gradle 中引入gson compile 'com.google.code.gson:gson:2.8.5' 2.将后台返回的json数据转对象.List.时间格式与后台返回的时间 ...

  7. Java 避免精度丢失之BigDecimal 运算

    * 由于Java的简单类型不能够精确的对浮点数进行运算,这个工具类提供精确的浮点数运算,包括加减乘除和四舍五入 import java.math.BigDecimal; /** 计算工具类 */ pu ...

  8. Centos7系统中安装Nginx1.8.0

    Nginx的安装 tar -zxvf nginx-1.8.0.tar.gz cd nginx-1.8.0 ./configure make make install /usr/local/nginx/ ...

  9. wait&waitpid状态值

    [wait&waitpid状态值] 1.  python 中 os.system 的返回值的format与wait的返回值status一致: On Unix, the return value ...

  10. [整理]基于bootstrap的文本编辑器

    http://www.bootcss.com/p/bootstrap-wysiwyg/ http://jhollingworth.github.io/bootstrap-wysihtml5/ http ...