title: HTTP posts and multiple threads in Java
body: <p>I am writing an internal Java Applet to do file uploads via HTTP.  I started using the built in ClientHttpRequest which worked great if I want to post one after another.  When I try to have multiple threads post at the same time, something on the server side freaks out and the connection will hang for large files while still uploading the smaller files.  (Large seems to be around 10 megs)  After lots of looking, I would not able to find a timeout that I could set to recover from this error, but finally found ClientHttp from Apache which DOES provide a mechanism to set a timeout.  The problem with it is that while it claims to be able to work in a multi-threaded program, it actually only does one request after another.  I have found lots of example code for HttpClient which says it will work for multiple threads and have made adjustments to my code to incorporate those changes, but none of them make any difference, and I am still stuck with essentially 1 thread.</p>
  
  <p>While multiple threads really are not required for release (HttpClient does seem to be a bit faster than ClientHttpRequest), it would be really nice to get that extra speed boost since there are a lot of smaller files that could be sent at the same time.</p>
  
  <p>The files are being sent over HTTP because we want to use the same authentication of the already logged in user using their session cookies.</p>
  
  <p>So I am looking for either a way to set a timeout with ClientHttpRequest or code for HttpClient that will actually send multiple requests at the same time as promised.</p>
  
  <p>I am sharing the same HttpClient instance between threads and using the multithreaded connection manager (it won't even work without this) like the docs say and it doesn't help.</p>
  
  <p>Any help would be appreciated and let me know if you need any clarifications.</p>