Skip to content

Instantly share code, notes, and snippets.

@maxant
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxant/214a03ee437777dad475 to your computer and use it in GitHub Desktop.
Save maxant/214a03ee437777dad475 to your computer and use it in GitHub Desktop.
//type 1
Future<String> f = service.foo(s);
String s = f.get(); //blocks the thread, but at least others can run
//... do something useful with the string...
//type 2
Future<String> f = service.foo(s);
while(!f.isDone()){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
...
}
}
String s = f.get();
//... do something useful with the string...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment