title: File from multithreaded download different from single threaded
body: <p>I have been experimenting with multithreading lately, and I coded an application that downloads a file with HTTPUrlConnection's Range request property. I first get the length of the file from the header, and then I split it up into X number of equal parts, and if there is a remainder, I assign one more thread to take up the slack. Then each of the parts go into an object inside of a queue. Then multiple threads access each task in the queue and execute it, downloading each part concurrently into separate files.</p>
  
  <p>The way that I join the files is the problem. No matter whether I use Linux <code>cat</code> or Windows' <code>copy /B</code> or <code>type</code>, it always comes out that the resulting file comes out invalid in some way. </p>
  
  <p>With AVI files, the index is broken, but when rebuilt, the AVI plays correctly. With .rar files winrar displays "unexpected end of archive", although the files extract normally. What could be causing this. I made sure that no bytes overlapped when I split it up amongst threads.</p>