Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • You can synchronize the entire operation, synchronize the individual steps, or invent some sort of "soft" scheme that will tolerate inconsistency.
    – Hot Licks
    Commented Mar 14, 2014 at 12:03
  • 1
    @HotLicks : just added some more details. there is another method too which returns a value from map2. which locks should be used? map1 or map2? in method1 and getFirstName() methods? Commented Mar 14, 2014 at 12:09
  • You just need to lock against THE EXACT SAME OBJECT in ALL methods which access the sets (in a manner where their being in sync is important). Could be map1, map2, or something else. There are those who strongly advocate using a specific singletonish lock object, but I'm not convinced of that.
    – Hot Licks
    Commented Mar 14, 2014 at 12:17