java - Future get(),如果未完成,是否会阻塞调用?

标签 java jdbc future

我在 DAO 类中有一个函数,它在数据库上运行存储的函数。我只希望在上次对该操作的调用完成后再次运行该操作。所以我的函数返回一个 Future 对象。

public Future<String> storedFunctionResultFuture()
{
   // calls the stored function
   return new AsyncResult<String>(result);
}

现在,如果我调用 storedFunctionResultFuture().get(),如果存储函数仍在运行过程中,get() 方法会阻止调用吗/还没完?

最佳答案

来自documentation

Waits if necessary for the computation to complete, and then retrieves its result.

所以,简短的回答是 - 是的。

关于java - Future get(),如果未完成,是否会阻塞调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27231416/

相关文章:

java - 之后我可以用 hibernate 替换 JDBC 逻辑吗

php - SQL如何查出数据位于哪个表

postgresql - DB 的 Scala future

Java 8 CompletableFuture - 扇出实现

java - 当 V 是 T 中的属性对象时,如何将数组 T[] 转换为 V[]

java - 实现 OnClickListener VS。新的 Button.OnClickListener() {};

java - Eclipse java JAX-RPC Web服务导入生成接口(interface)而不是类

java - 如何让 HttpAsyncClient 异步操作?

java - com.microsoft.sqlserver.jdbc.SQLServerException : This operation is not supported

scala - 使用 Scalaz Futures 和定时函数时如何正确退出程序