DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=35372>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35372





------- Additional Comments From [EMAIL PROTECTED]  2005-06-17 22:20 -------
Boris,
Since you are just streaming out files from multiple threads I think the same
net result can be achieved without going through all these hoops:

static class WorkerThread extends Thread {
    
    // Reference to a common/global HttpClient instance 
    private final HttpClient httpclient;
    // Target uri 
    private final String target;
    // entity to be streamed out
    private final RequestEntity entity;
    
    private Throwable exception = null;
    
    public WorkerThread(final HttpClient httpclient, final String target, final
File file) 
            throws IOException {
        super();
        this.httpclient = httpclient; 
        this.target = target;
        this.entity = new InputStreamRequestEntity(new FileInputStream(file));
    }
    
    public void run() {
        // Note the use of relative URL
        PostMethod httppost = new PostMethod(this.target);
        httppost.setRequestEntity(this.entity);
        try {
            this.httpclient.executeMethod(httppost);
            // Do something useful with the response body
        } catch (IOException ex) {
            // keep the exception for the post-mortem analysis
            this.exception = ex;
        } finally {
            httppost.releaseConnection();
        }
    }
    
}

public static void main(String[] args) throws Exception {
    
    MultiThreadedHttpConnectionManager connman = new
MultiThreadedHttpConnectionManager(); 
    HttpClient httpclient  = new HttpClient(connman);
    
    WorkerThread[] workers = new WorkerThread[] { 
        new WorkerThread(httpclient, "http://host1/stuff";, new File("stuff1")), 
        new WorkerThread(httpclient, "http://host2/stuff";, new File("stuff2")), 
        new WorkerThread(httpclient, "http://host3/stuff";, new File("stuff3")) 
    };
    for (int i = 0; i < workers.length; i++) {
        workers[i].start();
    }
    for (int i = 0; i < workers.length; i++) {
        workers[i].join();
    }
}
    
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to