IntermediateHttpClient interClient = new IntermediateHttpClient();
((ThreadSafeClientConnManager)interClient.getConnectionManager()).setMaxTotal(100);
CacheConfig config = new CacheConfig();
config.setMaxObjectSizeBytes(2<<24);
CachingHttpClient httpclient = new CachingHttpClient(new IntermediateHttpClient(), new Cache((long)2<<34, "places"), config);
try {
// create an array of URIs to perform GETs on
String[] urisToGet = {
"http://www.gutenberg.org/files/76/76-h/76-h/76-h.htm",
"http://www.gutenberg.org/cache/epub/10947/pg10947.html"
//"http://hc.apache.org/httpcomponents-client-ga/",
//"http://svn.apache.org/viewvc/httpcomponents/"
};
// create a thread for each URI
GetThread[] threads = new GetThread[10];
for (int i = 0; i < threads.length; i++) {
HttpGet httpget = new HttpGet(urisToGet[i%2]);
threads[i] = new GetThread(httpclient, httpget, i + 1);
}
// start the threads
for (int j = 0; j < threads.length; j++) {
threads[j].start();
// threads[j].join();
}
// join the threads
for (int j = 0; j < threads.length; j++) {
threads[j].join();
}
} finally {
// When HttpClient instance is no longer needed,
// shut down the connection manager to ensure
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
}
}