HttpClient 4 - What happened to MultiThreadedHttpConnectionManager?
Solution 1
In 4.x, the equivalent is Pooling connection manager. You can read more details on its usage in section Pooling connection manager here. I would also strongly suggest you to read this thread on their forum.
Solution 2
There's no indication in the javadoc that a DefaultHttpClient
instance is thread-safe.
So, I think you should just create an HttpClient
instance for each activity ... using a common/shared ThreadSafeClientConnManager
instance. That should allow you to reuse connections between HttpClient
instances. Just make sure that you don't shut down the connection manager.
The APIs are sufficiently different between version 3.x and 4.x that I'd be surprised if the examples for one were instructive for the other.
Hervé Donner
Updated on June 15, 2022Comments
-
Hervé Donner almost 2 years
I'm writing a swing application with HttpClient 4.
I followed the standard approach by passing a
ThreadSafeClientConnManager
to my sharedHttpClient
instance for now. But now I would like to be able to execute multiple requests/downloads at the same time...I found some examples with
MultiThreadedHttpConnectionManager
forHttpClient 3.x
but can I use it for version 4.x ? If so how ? I tried it but without success...Thanks ;)