我在 DAO 类中有一个函数,它在数据库上运行存储的函数。我只希望在上次对该操作的调用完成后再次运行该操作。所以我的函数返回一个 Future
对象。
public Future<String> storedFunctionResultFuture()
{
// calls the stored function
return new AsyncResult<String>(result);
}
现在,如果我调用 storedFunctionResultFuture().get()
,如果存储函数仍在运行过程中,get()
方法会阻止调用吗/还没完?
最佳答案
Waits if necessary for the computation to complete, and then retrieves its result.
所以,简短的回答是 - 是的。
关于java - Future get(),如果未完成,是否会阻塞调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27231416/