【发布时间】:2014-04-23 20:51:38
【问题描述】:
我有以下代码,我希望 a.success(burncpu(14969)) 会立即返回,因为它会在未来运行,但为什么它需要很长时间才能运行。
import scala.concurrent._
val a=Promise[Unit]()
// why the following took long time here, shouldn't it be in async mode, and return very quick
a.success(burncpu(14969))
a.future
def burncpu(a:Int):Int = {
val point=new Date().getTime()
while ((new Date()).getTime()-point< a) {
a
}
a
}
【问题讨论】: