Kill or timeout a Future in Scala 2.10

前端 未结 3 1898
失恋的感觉
失恋的感觉 2021-01-04 20:11

Hi,

I\'m using Scala 2.10 with the new futures library and I\'m trying to write some code to test an infinite loop. I use a scala.concurrent.Future to r

3条回答
  •  悲&欢浪女
    2021-01-04 20:19

    No - you will have to add a flag that your loop checks. If the flag is set, stop the loop. Make sure the flag is at least volatile.

    See Java Concurrency in Practice, p 135-137.

提交回复
热议问题