title: Multithreading a massive file read
body: <p>I'm still in the process of wrapping my brain around how concurrency works in Java. I understand that (if you're subscribing to the OO Java 5 concurrency model) you implement a <code>Task</code> or <code>Callable</code> with a <code>run()</code> or <code>call()</code> method (respectively), and it behooves you to parallelize as much of that implemented method as possible.</p>
  
  <p>But I'm still not understanding something inherent about concurrent programming in Java:</p>
  
  <ul>
  <li>How is a <code>Task</code>'s <code>run()</code> method assigned the right amount of concurrent work to be performed?</li>
  </ul>
  
  <p>As a concrete example, what if I have an I/O-bound <code>readMobyDick()</code> method that reads the entire contents of Herman Melville's <em>Moby Dick</em> into memory from a file on the local system. And let's just say I want this <code>readMobyDick()</code> method to be concurrent and handled by 3 threads, where:</p>
  
  <ul>
  <li>Thread #1 reads the first 1/3rd of the book into memory</li>
  <li>Thread #2 reads the second 1/3rd of the book into memory</li>
  <li>Thread #3 reads the last 1/3rd of the book into memory</li>
  </ul>
  
  <p><strong>Do I need to chunk Moby Dick up into three files and pass them each to their own task, or do I I just call <code>readMobyDick()</code> from inside the implemented <code>run()</code> method and (somehow) the <code>Executor</code> knows how to break the work up amongst the threads.</strong></p>
  
  <p>I am a very visual learner, so any code examples of the right way to approach this are greatly appreciated! Thanks!</p>