akka 演员工具包 - context.actorOf 与 system.actorOf

akka actors Toolkit - context.actorOf vs system.actorOf

你能给我解释一下

有什么区别吗

context.actorOf

system.actorOf

?

这个问题的答案很容易在 Akka 文档中找到:

An actor system is typically started by creating actors beneath the guardian actor using the ActorSystem.actorOf method and then using ActorContext.actorOf from within the created actors to spawn the actor tree.

  • System.actorOf 生成的 actor 将是 children 守护者 actor。
  • 使用 context.actorOf 生成的参与者将是上下文本身的 children - 即调用该方法的参与者。

作为一个更一般的建议,确保在搜索类似答案时彻底浏览 Akka 文档。