Scala - ScheduledFuture

前端 未结 7 1126
感动是毒
感动是毒 2020-12-08 04:27

I am trying to implement scheduled future in Scala. I would like it to wait specific time and then execute the body. So far I tried the following, simple approach

         


        
7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 05:11

    Akka has akka.pattern:

    def after[T](duration: FiniteDuration, using: Scheduler)(value: ⇒ Future[T])(implicit ec: ExecutionContext): Future[T]
    

    "Returns a scala.concurrent.Future that will be completed with the success or failure of the provided value after the specified duration."

    http://doc.akka.io/api/akka/2.2.1/#akka.pattern.package

提交回复
热议问题