Java fine-grained synchronization in getter/setter methods and singleton pattern of a class
问题 I'm trying to use the synchronization java directive to implement fine-grained synchronization in a class, i.e. synchronize the least amount of code I can.. I'll comment the code inline, to explain what I do and after the code I'll ask you how to improve the code: public class MyClass { private static volatile MyClass singletonInstance = null; private HashMap<String, Integer> mHashMap = null; private String mStringA = null; private String mStringB = null; // Use double check technique to use