Java BufferedReader readline blocking?
- by tgguy
I want to make an HTTP request and then get the response as sketched here:
URLConnection c = new URL("http://foo.com").openConnection();
c.setDoOutput(true);
/* write an http request here using a new OutputStreamWriter(c.getOutputStream) */
BufferedReader reader = new BufferedReader(new InputStreamReader(c.getInputStream));
reader.readLine();
But my question is, if the request I send takes a long time before a response is received, what happens in the call reader.readLine() above? Will this process stay running/runnable on the CPU or will it get taken off the CPU and be notified to wake up and run again when there is IO to be read?
If it stays on the CPU, what can be done to make it get off and be notified later?