Hi,

Will I run into any problems with the following code? Specifically
using the httpGet in more than one thread?


// might pass in a ThreadSafeClientConnManager here
        final DefaultHttpClient httpclient = new DefaultHttpClient();

        List<HttpHost> hosts = new ArrayList<HttpHost>();
        hosts.add(new HttpHost("www.host1.com"));
        hosts.add(new HttpHost("www.host2.com"));
        hosts.add(new HttpHost("www.host3.com"));

        String request = "/path/to/something?name=value&name1=value1";

        final HttpGet httpGet = new HttpGet(request);
        // set some headers here.

        for ( final HttpHost host : hosts ) {
            taskExecutor.execute(new Runnable() {
                public void run() {

                    try {
                        HttpResponse response =
httpclient.execute(host, httpGet);
                        // do what every with the response

                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                }
            });
        }

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to