【发布时间】:2012-05-20 21:12:10
【问题描述】:
我试图在新的 Scala 2.10 futures feature 上重现该示例。 我使用的代码是:
import scala.concurrent.Future
import scala.concurrent.future
object Test {
def main(args: Array[String]) {
println("Test print before future")
val s = "Hello"
val f = future {s + " future!"}
f onSuccess {case v => println(v)}
println("Test print after future")
}
}
代替打印:
Test print before future
Hello future!
Test print after future
它只是打印:
Test print before future
Test print after future
知道我为什么会有这种行为吗?我的 scala 编译器版本是 2.10.0-20120507。
【问题讨论】:
标签: scala concurrency future