Code example for ThreadSafeClientConnManager

Methods: setDefaultMaxPerRoute, setMaxTotal

	private ThreadSafeClientConnManager connectionManager;
    private final DefaultHttpClient client;
    public HttpFetchProtocol() 
        this.connectionManager = new ThreadSafeClientConnManager();
        this.client = new DefaultHttpClient(this.connectionManager);
        this.client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "BagIt Library Parallel Fetcher");
        // Since we control the threading manually, set the max 
        // configuration values to Very Large Numbers. 
    	// Set the socket timeout, so that it does not default to infinity. 
    	// Otherwise, broken TCP steams can hang threads forever. 
        client.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 20 * 1000);
		client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 20 * 1000);
Stop searching for code, let great code find you!  Add Codota to your java IDE