title: ThreadPoolExecutor with fix poolsize and many task
body: <p>I have a problem with ThreadPoolExecutor. There is a list which contains many file name.
  I want to process these files with multithreading. I only want 2 or 4 threads (depends on the processor) in one time. Sometimes if the files are long I get out of memory exception. 
  I investigated the problem with no result...</p>
  
  <p>The code:</p>
  
  <pre><code>ThreadPoolExecutor executor = new   ThreadPoolExecutor(2, 2,
                  0L, TimeUnit.MILLISECONDS,
                  new ArrayBlockingQueue&lt;Runnable&gt;(20));
  </code></pre>
  
  <p>I store the file names in a list then I iterate through the list one-by-one and call the <code>execute()</code> method.</p>
  
  <pre><code>for(String fileName : fileNames) {
     executor.execute(new FileProcess(fileName));
  }    
  </code></pre>
  
  <p>Then <code>shutdown()</code> the poolThread and wait for every thread are finish. </p>
  
  <pre><code>    if (ProjectsHandler.withThread){
          executor.shutdown();
          while(!executor.isTerminated()) {
              // wait until all threads are finish
          }
      }
  </code></pre>
  
  <p>So I gave out of memory exception. The profiler said the cause is the ThreadPoolExecutor.
  If I run the program with 1 thread everything is ok, no exception.</p>
  
  <p>What could be the problem? 
  Thanks in advance</p>