Reputation: 1661
Is there a better way to send thousands of http GET requests at the same time? My code sends requests one after other. Have looked at other answers but could not figure it out. Thanks.
for (int j=0; j<4; j++) {
DefaultHttpClient httpclient = new DefaultHttpClient();
CookieStore cookieStore = httpclient.getCookieStore();
HttpGet httpget = new HttpGet("");
try {
HttpResponse response = httpclient.execute(httpget);
List<Cookie> cookies = cookieStore.getCookies();
} catch (Exception e) {}
httpclient.getConnectionManager().shutdown();
}
Upvotes: 5
Views: 14256
Reputation: 26717
you should create multiple threads and each of them should perform an HTTP Request
the below link may help
http://hc.apache.org/httpclient-3.x/threading.html
Upvotes: 3