Last active
August 29, 2015 14:12
-
-
Save maxant/214a03ee437777dad475 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//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