title: Apache async HttpClient not fast
body: <p>I am pretty new to Apache http client and am trying to get status code from a website. Found the following example on Apache http tutorial.</p>
  
  <pre><code>import java.util.concurrent.CountDownLatch;
  import org.apache.http.HttpResponse;
  import org.apache.http.client.config.RequestConfig;
  import org.apache.http.client.methods.HttpGet;
  import org.apache.http.concurrent.FutureCallback;
  import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
  import org.apache.http.impl.nio.client.HttpAsyncClients;
  public class Abc {
      static long d2;
      public static void main(final String[] args) throws Exception {
          d2=System.currentTimeMillis();
          RequestConfig requestConfig = RequestConfig.custom()
              .setSocketTimeout(3000)
              .setConnectTimeout(3000).build();
          CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom()
              .setDefaultRequestConfig(requestConfig)
              .build();
          try {
              httpclient.start();
              final HttpGet[] requests = new HttpGet[] {
                      new HttpGet("http://192.168.26.175:8080/examples/eye/abc10000.jsp")
              };
              final CountDownLatch latch = new CountDownLatch(1);
              for (int v=0;v&lt;1000;v++) {
                  httpclient.execute(requests[0], new FutureCallback&lt;HttpResponse&gt;() {
  
                      public void completed(final HttpResponse response) {
                          latch.countDown();
                          System.out.println(requests[0].getRequestLine() + "-&gt;" + response.getStatusLine());
                      }
  
                      public void failed(final Exception ex) {
                          latch.countDown();
                          System.out.println(requests[0].getRequestLine() + "-&gt;" + ex);
                      }
  
                      public void cancelled() {
                          latch.countDown();
                          System.out.println(requests[0].getRequestLine() + " cancelled");
                      }
  
                  });
              }
              latch.await();
              System.out.println("Shutting down");
          } finally {
              httpclient.close();
          }
          System.out.println("Done");
        long  d1=System.currentTimeMillis();
        System.out.println(d1-d2);
      }
  
  }
  </code></pre>
  
  <p>Is it really asynchronous or are the calls made serially. What has to be done to make calls asynchronous and faster.</p>