欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Java 并发 博客分类: java concurrent

程序员文章站 2024-03-06 19:24:02
...

private Map<Integer, Object> map = new ConcurrentHashMap<Integer, Object> ();

 

@unsafe

public void putIfAbsent(Integer key,  String value){

         if (!map.containsKey(key)) {
            map.put(key, value);
        }

}

 

------------------------------------------------------------------------------------------------

如何修改优化

public void putIfAbsent(final Integer key,  final String value){
          map.putIfAbsent(key, value);

}

 

get , if null then put

 

CountDownLatch, Future, FutureTask

相关标签: concurrent