简体   繁体   中英

akka actors framework - context.actorOf vs system.actorOf

Could you please explain me what is the difference between

context.actorOf

and

system.actorOf

?

Answer to this can be easily found in the Akka documentation:

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.

  • Actors spawned with System.actorOf will be children of the guardian actor.
  • Actors spawned with context.actorOf will be children of the context itself - ie the actor which invokes the method.

As a more general suggestion, make sure you thoroughly explore Akka docs when in search of similar answers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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