I am making a call to REST URL and trying to measure how much time it is taking to get the response back.
I am using DefaultHttpClient
for that to get t
Is there anything wrong I am doing here?
Yes. As stated in the docs:
BasicClientConnectionManager is a simple connection manager that maintains only one connection at a time. Even though this class is thread-safe it ought to be used by one execution thread only. BasicClientConnectionManager will make an effort to reuse the connection for subsequent requests with the same route. It will, however, close the existing connection and re-open it for the given route, if the route of the persistent connection does not match that of the connection request. If the connection has been already been allocated, then java.lang.IllegalStateException is thrown.
BasicClientConnectionManager is used by HttpClient per default.
See "Multithreaded request execution" on how to use a pooling connection manager that can handle requests across multiple threads.