How to wait for Akka actor system to terminate?

前端 未结 7 693
温柔的废话
温柔的废话 2020-12-25 14:19

I need to start Akka (2.0) actor system, send in some messages, then wait for it to do heavy lifting. After that, I need to do something unrelated to those actors.

I

相关标签:
7条回答
  • 2020-12-25 15:22

    How about:

    import scala.concurrent.Await
    import scala.concurrent.duration._
    
    Await.ready(system.terminate(), 5.seconds)
    

    terminate returns a Future:

    def terminate(): Future[Terminated]
    

    and you can just await completion of this future.

    0 讨论(0)
提交回复
热议问题