私は私が使用していますこれらの要求を行うために、異なる目的のために異なるAPIを使用してマルチスレッドのRESTクライアントを書いていて、異なる方法(POST、GET、PUT)効率的な方法
とのHttpClientをスレッド1:
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
httpclient.execute(httppost);
methodThatNeedsHttpClient(httpclient);
public void methodThatNeedsHttpClient(HttpClient client) {
//perform other GET/POST/PUT requests
}
スレッド2:
DefaultHttpClient httpclient2 = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
httpclient2.execute(httppost);
// Other methods
私はhttpConnectionsを管理するために、私はConnection Managerを使用しなければならないことをお読みください。私は接続マネージャーが使用するはずのクライアントのバージョン4.5を使用していますか?接続マネージャは、接続が確実にリークしないようにして、効率的に使用しますか?
私は、次の実装しようとした:
PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
connectionManager.setMaxTotal(5);
// Perform REST operations
client.getConnectionManager().shutdown();
をしかし、私は接続がプール内で管理されているかわからない、マルチスレッドシステムのため、接続マネージャは、すべてのスレッドで初期化されるのでしょうか?