You may want to consider doing something like this, having a manager for the actors to know when they are done.
class HelloManager(urls: List[String]) extends Actor {
var completed = 0
def remaining = urls.size - completed
def receive: Receive = {
case StartSystem => startRequests
case RequestComplete => handleComplete
}
def startRequests(): Unit = {
for ((url, i) <- urls.zipWithIndex) {
val helloActor = context.actorOf(Props[HelloActor], name = s"helloActor$i")
helloActor ! UrlTransport(url)
}
}
def handleComplete(): Unit = {
completed += 1
if (remaining == 0)
// do something like
// context.stop(self)
}
}
Then you just need the HelloActor to do a sender ! RequestComplete
when it is done with its job.