本文整理匯總了Java中org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager.setMaxTotal方法的典型用法代碼示例。如果您正苦於以下問題:Java ThreadSafeClientConnManager.setMaxTotal方法的具體用法?Java ThreadSafeClientConnManager.setMaxTotal怎麽用?Java ThreadSafeClientConnManager.setMaxTotal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager
的用法示例。
在下文中一共展示了ThreadSafeClientConnManager.setMaxTotal方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ProxyService
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; //導入方法依賴的package包/類
public ProxyService() {
final ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager();
final HttpRoute route = new HttpRoute(new HttpHost(
"http://accept.ps4.uitburo.nl/"));
cm.setDefaultMaxPerRoute(100);
cm.setMaxForRoute(route, 100);
cm.setMaxTotal(100);
client = new DefaultHttpClient(cm);
}
示例2: poolManager
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; //導入方法依賴的package包/類
public static ThreadSafeClientConnManager poolManager(int maxConnections) {
ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager();
cm.setMaxTotal(maxConnections);
cm.setDefaultMaxPerRoute(maxConnections);
return cm;
}
示例3: main
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; //導入方法依賴的package包/類
public static void main(String[] args) {
ThreadSafeClientConnManager conn = new ThreadSafeClientConnManager();
conn.setMaxTotal(100);
HttpClient hc = new DefaultHttpClient(conn);
String[] uritoget = {
"http://jakarta.apache.org/",
"http://jakarta.apache.org/commons/",
"http://jakarta.apache.org/commons/httpclient/",
"http://svn.apache.org/viewvc/jakarta/httpcomponents/"
};
IdleConnectionEvictor connEvictor = new IdleConnectionEvictor(conn);
connEvictor.start();
try {
for (int i = 0; i < uritoget.length; i++) {
String uri = uritoget[i];
HttpGet get = new HttpGet(uri);
System.out.println("executing = " + uri);
HttpResponse res = hc.execute(get);
HttpEntity entity = res.getEntity();
System.out.println("status = " + res.getStatusLine());
if (entity != null) {
System.out.println("content length = " + entity.getContentLength());
EntityUtils.consume(entity);
}
}
Thread.sleep(20000);
connEvictor.shutdown();
connEvictor.join();
} catch (Exception e) {
e.printStackTrace();
} finally {
hc.getConnectionManager().shutdown();
}
}