Tweaked example app

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1483382 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2013-05-16 14:15:11 +00:00
parent 077dbc687a
commit 4add562f6c
1 changed files with 69 additions and 66 deletions

View File

@ -53,8 +53,9 @@ public class ClientWithRequestFuture {
.setMaxConnPerRoute(5)
.setMaxConnTotal(5).build();
ExecutorService execService = Executors.newFixedThreadPool(5);
FutureRequestExecutionService requestExecService = new FutureRequestExecutionService(httpclient, execService);
FutureRequestExecutionService requestExecService = new FutureRequestExecutionService(
httpclient, execService);
try {
// Because things are asynchronous, you must provide a ResponseHandler
ResponseHandler<Boolean> handler = new ResponseHandler<Boolean>() {
public Boolean handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
@ -125,6 +126,8 @@ public class ClientWithRequestFuture {
for (Future<Boolean> future : futureTask) {
System.out.println("another result " + future.get());
}
} finally {
requestExecService.close();
}
}
}