How to wait for Akka actor system to terminate?

前端 未结 7 691
温柔的废话
温柔的废话 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条回答
  •  梦毁少年i
    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.

提交回复
热议问题