HttpConnectionManager connectionManager =
new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = connectionManager.getParams();
params.setIntParameter( HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, 2 );
params.setIntParameter( HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, 4 );
List retrievers = new ArrayList();
for( int i = 0; i < 20; i++ ) {
HttpClient client = new HttpClient(connectionManager);
Thread thread = new Thread( new PageRetriever(client) );
retrievers.add( thread );
}
Iterator threadIter = retrievers.iterator();
while( threadIter.hasNext() ) {
Thread thread = (Thread) threadIter.next();
thread.start();
}