检查未来的价值

アレッ*_*ックス 1 scala future

我想f通过查看其持有的价值来检查Future 是否现在完成.那不是

f onComplete {

}
Run Code Online (Sandbox Code Playgroud)

它是关于检查它当前没有阻塞的值.

你的意见?

ste*_*tew 9

f.value match {
  case Some(Success(x)) => println(s"the future is completed successfully with value $x")
  case Some(Failure(e)) => println(s"the future failed with an error: $e")
  case None => println("the future has not yet completed")
}
Run Code Online (Sandbox Code Playgroud)