This article describes the Java implementation httpclient asynchronous request resources. Share to everyone for your reference. The implementation method is as follows:
Package demo;
Import Java.util.concurrent.CountDownLatch;
Import Org.apache.http.HttpResponse;
Import Org.apache.http.client.methods.HttpGet;
Import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
Import org.apache.http.nio.client.HttpAsyncClient;
Import Org.apache.http.nio.concurrent.FutureCallback;
Import org.apache.http.nio.reactor.IOReactorException; public class Main {/** * @param args * @throws ioreactorexception * @throws interruptedexception/Public St atic void Main (string[] args) throws Ioreactorexception, interruptedexception {final httpasyncclient httpclient = new D
Efaulthttpasyncclient ();
Httpclient.start (); Httpget[] Requests = new httpget[] {new HttpGet ("http://www.apache.org/"), New HttpGet ("https://www.verisign.com/
"), New HttpGet (" http://www.google.com/")};
Final Countdownlatch latch = new Countdownlatch (requests.length); try {for (final httpget request:requests) {httpclient.execute (Request, new FuturecallbacK
I hope this article will help you with your Java programming.