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?
Use multiple threads; a pool of 1000 threads will drop your elapsed time by a factor of 1000.
Use non-blocking I/O. Running 1000 concurrent connections will drop your total time by a factor of 1000.
精彩评论