System.currentTimeMillis() not giving correct results when measuring network latency
Posted on 2006-07-19
Here is a fragment of my code:
// POP server logon code here
startTimer = System.currentTimeMillis();
os.write("list\r\n".getBytes()); // send LIST command to POP server
bytesRead = is.read(inputBuffer, 0, bufferSize); // read data sent from POP server
stopTimer = System.currentTimeMillis();
I am basically try to measure the amount of time it takes to do a LIST and for the server to return the result. The first time the loop runs, I get a reasonable time difference (stopTimer - startTimer) about 150ms. However for all the other 9 loops I get 0.
Why is this the case?