title: Synchronize the PoolingClientConnectionManager or not
body: <p>In my app more than one <em>IntentService</em> connect/communicate with a <em>Tomcat</em> server at random intervals depending on user interaction with the application.</p>
  
  <p>I am using the following Singleton for Http</p>
  
  <pre><code>public class CustomHttpClient { 
      private static HttpClient customHttpClient; 
      /** A private Constructor prevents instantiation */ 
      private CustomHttpClient() { 
      } 
  
      public static synchronized HttpClient getHttpClient() { 
          if (customHttpClient == null) { 
              HttpParams params = new BasicHttpParams(); 
              HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); 
              HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET); 
              HttpProtocolParams.setUseExpectContinue(params, true); 
              HttpProtocolParams.setUserAgent(params,"Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; Nexus One Build/FRG83)" +
                      " AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"); 
              ConnManagerParams.setTimeout(params, 1000); 
              HttpConnectionParams.setConnectionTimeout(params, 5000); 
              HttpConnectionParams.setSoTimeout(params, 10000); 
              SchemeRegistry schReg = new SchemeRegistry(); 
              schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); 
              schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); 
              ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params,schReg); 
              customHttpClient = new DefaultHttpClient(conMgr, params); 
          } 
          return customHttpClient; 
      } 
      public Object clone() throws CloneNotSupportedException { 
          throw new CloneNotSupportedException(); 
      } 
  }
  </code></pre>
  
  <p>The class works fine except it gives <em>connectTimeOut</em> whenever two <code>IntentService</code> try to Http at the same time or when one connection is in progress and another connection is established.</p>
  
  <p>One obvious improvement in the code is to replace deprecated <code>ThreadSafeClientConnManager</code> with <code>PoolingClientConnectionManager.</code></p>
  
  <p>Should I <code>synchronize</code> here -> <code>public static synchronized HttpClient getHttpClient()</code></p>
  
  <p>What error in the Singleton is causing the <em>connectTimeOut</em>? </p>