TheAkkaWay icon indicating copy to clipboard operation
TheAkkaWay copied to clipboard

在Actor外部对Actor内部属性进行只读操作会不会有问题?

Open holdbelief opened this issue 8 years ago • 1 comments

在一个actor内有一个 list 如果在actor内部对list进行写操作 在actor外部对list进行【只读】操作 是不是会有线程安全问题?

holdbelief avatar Apr 14 '17 04:04 holdbelief

会有的,外部改这个状态的时候会出问题

这里的思维方式是不对的,Actor内部的状态需要安全的发布出去,如果是一个不可变的列表发布出去没啥子事情的.

Actor外部只能通过ActorRef发消息和他交互

He-Pin avatar Apr 14 '17 06:04 He-Pin