I’ve write sample code that starts an actor, kills it and finishes execution.
object PureAkka {
def main(argv : Array[String]) = {
val actorSystem : ActorSystem = ActorSystem("main")
val actor : ActorRef = actorSystem.actorOf(Props( new Actor {
override def receive = {
case x => println(x)
}
override def preStart() = println("prestart")
override def postStop() = println("poststop")
} ) )
Thread.sleep(15000)
actor ! PoisonPill
}
}
This code prints:
[info] prestart
[info] poststop
But it refuses to stop until I kill the process with Ctrl-C
What does application wait for? How can I stop it in a proper way?
Perhaps making a call to ActorSystem.shutdown() would do the trick.
According to the akka docs: