Timeout Exceptions
<p>This is my below code, I am confuse why this thing is happening. In this code getLocationByIpTimeout is a method in which I am passing two things- one is the ip address and second is the timeout in milliseconds. So I will get the timeout exception if the response is not getting back in under 5 milliseconds in this particular case. So when I ran this below code, I am getting few timeout exceptions for few ip address that means some response is taking longer time(greater than 5 ms) but the most important thing that I am confuse is if I am getting timeout exceptions  (time taken to get the response is greater than 5 ms) then why the program is entering in that if loop in which I am having difference > 5. It should have thrown the timeout exception at previous place. What can be the possible reason for this? It is because of catch block?? Any suggestions will be appreciated.</p>

<pre><code>long runs = 10000;
long difference = 0;

while (runs &gt; 0) {
    String ipAddress = generateIPAddress();
    long start_time = System.nanoTime();

    try {
        resp = PersonalizationGeoLocationServiceClientHelper.getLocationByIpTimeout(ipAddress, 5);
    } catch (TimeoutException e) {
        System.out.println("Timeout Exception");
    }

    long end_time = System.nanoTime();

    if (resp == null || (resp.getLocation() == null)) {
        difference  = 0;
    } else if (resp.getLocation() != null) {
        difference = (end_time - start_time) / 1000000;
    }

    if (difference&gt; 5) {
        System.out.println("Debug");
    }

}
</code></pre>

<p><strong>OUTPUT NOT EXPECTED</strong>
Ok. The problem that I am having is- It should print out <strong>Timeout Exception</strong> for any response greater than 5 milliseconds. But in some case what's happening is that it is printing Debug but without printing Timeout Exception and with the help of debugger I found that if the difference is around 6 or 8 then I saw pointer entering that if loop of debug.</p>
