Can Actors reply, which uses a thread local variable, cause a bug?

橙三吉。 提交于 2019-12-11 01:18:31

问题


I noticed that Actor reply invokes the reply method of a thread local variable of ReplyReactor type (see private methodrawSelf). This reply method sends a message to the senders.head, where the senders is a list of senders (see the source).

Now I wonder if it may cause a bug. What if two actors share one thread with a thread local ReplyReactor instance ? Is there a scenario, when one of the actors replies to a wrong sender ?


回答1:


Actors do share threads, but they cannot be interrupted. They'll run until the next react or end of loop, at which point they cannot reply anymore, before doing another react or receive.



来源:https://stackoverflow.com/questions/7065174/can-actors-reply-which-uses-a-thread-local-variable-cause-a-bug

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!