How to handle concurrent access to a Scala collection?

后端 未结 4 1939
悲哀的现实
悲哀的现实 2021-01-04 11:11

I have an Actor that - in its very essence - maintains a list of objects. It has three basic operations, an add, update and a remove (where sometimes the remove is called fr

4条回答
  •  醉梦人生
    2021-01-04 11:31

    You don't need to synchronize the state of the actors. The aim of the actors is to avoid tricky, error prone and hard to debug concurrent programming.

    Actor model will ensure that the actor will consume messages one by one and that you will never have two thread consuming message for the same Actor.

提交回复
热议问题