내가 사용하고 이러한 요청을 들어, 서로 다른 목적을 위해 다른 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 관리를 위해 내가 연결 관리자를 사용한다는 것을 읽었다. 클라이언트 4.5 버전을 사용하고 있는데 어떤 연결 관리자를 사용해야합니까? 연결 관리자가 연결이 누출되지 않고 효율적으로 사용되도록하는 방법은 무엇입니까?
나는 다음과 같은 구현하려고 :PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
connectionManager.setMaxTotal(5);
// Perform REST operations
client.getConnectionManager().shutdown();
을하지만 연결 관리자는 모든 스레드에서 초기화 않고, 연결이 멀티 스레드 시스템, 풀에서 관리하는 방법을하지 확신?