4

有没有更好的方法同时发送数千个 http GET 请求?我的代码一个接一个地发送请求。看过其他答案,但无法弄清楚。谢谢。

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();
}
4

1 回答 1

3

您应该创建多个线程,每个线程都应该执行一个 HTTP 请求

以下链接可能会有所帮助

http://hc.apache.org/httpclient-3.x/threading.html

于 2012-12-11T15:26:59.733 回答