Scala - ScheduledFuture

前端 未结 7 1104
感动是毒
感动是毒 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:16

    All the other solutions use either akka or block a thread per delayed task. A better solution (unless you are already using akka) is to use java's ScheduledThreadPoolExecutor. Here's an example of a scala wrapper for that:

    https://gist.github.com/platy/8f0e634c64d9fb54559c

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