I believe that when you use the native Java method, the stack trace will indicate RUNNABLE, even if the call is actually blocked waiting for some event. In essence, I donβt believe that Java has any way of knowing what its own method is doing, so it designates these calls as RUNNABLE. I saw this with socketRead0 () and socketAccept () - both of which are usually blocked.
You need to set a timeout for a reasonable amount of time so that your request does not work if the server is not responding, but not too short if the server is just busy. Your application must be written to use multiple threads. I would try to start a dozen or more threads and each thread wait up to five or ten seconds to respond. There is virtually no overhead with multiple threads. You should also remember not to bombard the server with many requests when writing a web spider.
Geoff
source share