I have some pretty simple code to get the HTTP status code from a given url:
URL url = new URL(args[0]); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setConnectTimeout(10000); connection.setReadTimeout(10000); connection.setInstanceFollowRedirects(true); int code = connection.getResponseCode(); connection.disconnect(); System.out.print(code); System.exit(0);
Obviously, everything is inside try / catch blocks, but all they do is exit with an error. The code seemed to work, so I ran a list of urls. I tracked processes and noticed that some 10 Java instances were created on some URLs for the same URL.
In other words, I would run:
java -jar HTTP.jar {URL}
and see this command about 10 times when I started htop. They look like regular processes, not threads, but in htop I "hide threads of user threads". What's happening? Passed multiple requests or only one?
source share