Java multi-threading atomic reference assignment

前端 未结 4 1227
别跟我提以往
别跟我提以往 2020-12-08 03:02

I have a cache which I implemented using a simeple HashMap. like -

HashMap cache = new HashMap();

4条回答
  •  离开以前
    2020-12-08 03:42

    What about CopyOnWrite.. collections:

    java.util.concurrent.CopyOnWriteArraySet
    java.util.concurrent.CopyOnWriteArraySet
    and org.apache.mina.util.CopyOnWriteMap
    

    They can be a good match in your case and they are thread-safe.

提交回复
热议问题