Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public void runAsyncWorkersWithFutureReturnType() throws Exception
{
LOGGER.info(" start of returning async worker");
Future<String> future = asyncWorkerReturn.execute();
String result = (String) this.getResultOfFuture(future);
LOGGER.info(" returned result is [" + result + "] ");
}
private Object getResultOfFuture(Future future) throws Exception
{
if (future.isDone()) {
return future.get();
}
LOGGER.info(" waiting for result ");
Thread.sleep(1000);
return getResultOfFuture(future);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment