當前位置: 首頁>>代碼示例>>Java>>正文


Java ThreadSafeClientConnManager.setMaxTotal方法代碼示例

本文整理匯總了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);

	}
 
開發者ID:erfgoed-en-locatie,項目名稱:artsholland-platform,代碼行數:12,代碼來源:ProxyService.java

示例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;
}
 
開發者ID:aerogear,項目名稱:java-mpns,代碼行數:8,代碼來源:Utilities.java

示例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();
	}
}
 
開發者ID:toulezu,項目名稱:play,代碼行數:44,代碼來源:Test4.java


注:本文中的org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager.setMaxTotal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。