title: Java Client/Server File transfer with Multithreading Problem
body: <p>I want to create simple download accelerator. </p>
  
  <p>How it works</p>
  
  <ol>
  <li>Server wait for incoming connection.</li>
  <li>Client connect to server.</li>
  <li>Then, server send file size to client and wait for download connection.</li>
  <li>Client got file size, then create download thread and these thread are connect to server.</li>
  <li>After server got connection from each thread, server will wait for start and end offset file from thread.</li>
  <li>Each thread send start and end offset file to server.</li>
  <li>After server got offsets, server will send the portion of file to thread.</li>
  <li>Each thread will read and write to file. For example, buffer.p01, buffer.p02, buffer.p03</li>
  <li>Client merge all file into one file order by sequence. ( <strong>Not yet implemented</strong> )</li>
  </ol>
  
  <p>I think server side it works correctly but client side it has some problem.</p>
  
  <p>The problem is if I set MAXTHREAD to 1, it works correctly. But if I set more than one, it stuck somewhere forever.</p>
  
  <p>This is server side code..
  <a href="http://pastebin.com/TEakGB0c" rel="nofollow">http://pastebin.com/TEakGB0c</a></p>
  
  <p>and this is client side code with multithreading
  <a href="http://pastebin.com/wKhP7DxS" rel="nofollow">http://pastebin.com/wKhP7DxS</a></p>
  
  <p>Thanks your.</p>