Created
November 26, 2017 14:23
-
-
Save chathurangat/665e0e44b2f7b5fa16c883f9bf5e63f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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