public static void main(final String... args)throws Exception {
        // Use pool of two threads
        final ExecutorService threadpool = Executors.newFixedThreadPool(2);
        final Async async = Async.newInstance().use(threadpool);

        final Request[] requests = new Request[] {
                Request.get("http://www.google.com/"),
                Request.get("http://www.yahoo.com/"),
                Request.get("http://www.apache.org/"),
                Request.get("http://www.apple.com/")
        };


        final Queue<Future<Content>> queue = new LinkedList<>();
        // Execute requests asynchronously
        for (final Request request: requests) {
            final Future<Content> future = async.execute(request, new FutureCallback<Content>() {

                @Override
                public void failed(final Exception ex) {
                    System.out.println(ex.getMessage() + ": " + request);
                }

                @Override
                public void completed(final Content content) {
                    System.out.println("Request completed: " + request);
                }

                @Override
                public void cancelled() {
                }

            });
            queue.add(future);
        }

        while (!queue.isEmpty()) {
            final Future<Content> future = queue.remove();
            try {
                future.get();
            } catch (final ExecutionException ignore) {
            }
        }
        System.out.println("Done");
        threadpool.shutdown();
    }
This example demonstrates how the he HttpClient fluent API can be used to execute multiple
requests asynchronously using background threads.
httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentAsync.java