0

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

1
  • When you say crashes, do you have any stacktrace? Also, they recommend reusing instances. Also, what pool size have you configured? Maybe also worth taking a look at stackoverflow.com/questions/1281219/… Commented Mar 10, 2015 at 20:50

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

thanks a lot Brian. Is there a way to test this concurrency problems properly?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.