Reputation: 186
Hi all I use apache's httpclient to make restcalls, everything is working fine, When multiple thread are using this method my app crashes. What is the implementation for this class that is MultithreadSafe.
Here is my code.
httpClient = new HttpClient();
HttpMethod method = null;
method = new GetMethod();
... method creation...
httpClient.executeMethod(method);
method.releaseConnection();
Thanks in advance. Juan
Upvotes: 0
Views: 181
Reputation: 272307
Have you looked at the HttpClient threading documentation ?
To get started one must create an instance of the MultiThreadedHttpConnectionManager and give it to an HttpClient. This looks something like:
MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); HttpClient client = new HttpClient(connectionManager);
The issue you're having is quite common when using HttpClient out-of-the -box
Upvotes: 1