开发者

How can i get http response code more quickly in java than getResponseCode?

开发者 https://www.devze.com 2023-02-06 20:55 出处:网络
I want to get http response code of over 10000000 web sites. So, I used Http(s)?URLConnection class in java.

I want to get http response code of over 10000000 web sites. So, I used Http(s)?URLConnection class in java.

Code is

HttpURLConnection http = (HttpURLConnection)address.openConnection();
http.setReadTimeout(300000);
return http.getResponseCode();

But I think that it is very slow. When I calculate total time, it is over 10days开发者_如何学编程.

Do you know more fast function or other ways to get HTTP response code in Java?


  1. Use multiple threads; a pool of 1000 threads will drop your elapsed time by a factor of 1000.

  2. Use non-blocking I/O. Running 1000 concurrent connections will drop your total time by a factor of 1000.

0

精彩评论

暂无评论...
验证码 换一张
取 消