-
-
Save neotyk/575928 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
import com.ning.http.client.AsyncCompletionHandler; | |
import com.ning.http.client.AsyncHttpClient; | |
import com.ning.http.client.Request; | |
import com.ning.http.client.Response; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.concurrent.Future; | |
public class Problem { | |
public static void main(String[] args) throws Exception { | |
AsyncHttpClient client = new AsyncHttpClient(); | |
Request request = client | |
.prepareGet(String.format("http://example.com/")) | |
.build(); | |
List<Future<String>> fs = new ArrayList<Future<String>>(); | |
for (int i = 0; i < 7; i++) { | |
fs.add(client.executeRequest(request, new AsyncCompletionHandler<String>() { | |
@Override | |
public String onCompleted(Response response) throws Exception { | |
return response.getResponseBody(); | |
} | |
})); | |
} | |
for (Future<String> f : fs) { | |
System.out.println(f.get()); | |
} | |
client.close(); | |
System.out.println("Exiting..."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment