Java synchronized block vs. Collections.synchronizedMap

后端 未结 7 1905
天涯浪人
天涯浪人 2020-11-28 03:35

Is the following code set up to correctly synchronize the calls on synchronizedMap?

public class MyClass {
  private static Map

        
7条回答
  •  粉色の甜心
    2020-11-28 03:52

    If you are using JDK 6 then you might want to check out ConcurrentHashMap

    Note the putIfAbsent method in that class.

提交回复
热议问题