orpqK
orpqK

Reputation: 2795

Future get(), does it block calls if it's not finished?

I have a function in the DAO class that run a stored function on the data base. I only want this operation to run again if the previous call to this operation is finished. So my function returns a Future object.

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

Now if I call storedFunctionResultFuture().get(), will the get() method block the call if the stored function is still in the process of running / not finished yet?

Upvotes: 0

Views: 438

Answers (1)

Predrag Maric
Predrag Maric

Reputation: 24433

From the documentation

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

So, short answer is - yes.

Upvotes: 2

Related Questions