简体   繁体   English

akka actors framework - context.actorOf vs system.actorOf

[英]akka actors framework - context.actorOf vs system.actorOf

Could you please explain me what is the difference between 你能解释一下我之间有什么区别吗?

context.actorOf context.actorOf

and

system.actorOf system.actorOf

?

Answer to this can be easily found in the Akka documentation: 在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. 演员系统通常是通过使用ActorSystem.actorOf方法在守护者actor下创建actor,然后在创建的actor中使用ActorContext.actorOf来生成actor树来启动的。

  • Actors spawned with System.actorOf will be children of the guardian actor. 使用System.actorOf生成的演员将成为守护演员的孩子。
  • Actors spawned with context.actorOf will be children of the context itself - ie the actor which invokes the method. 使用context.actorOf生成的Actor将是上下文本身的子context.actorOf - 即调用该方法的actor。

As a more general suggestion, make sure you thoroughly explore Akka docs when in search of similar answers. 作为更一般的建议,请确保在搜索类似答案时彻底探索Akka文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM