Java 并发

阅读更多

private Map map = new ConcurrentHashMap ();

 

@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)