title: Parallel processing of files in java with ExecutorService does not use all of the CPU power
body: <p>I have a directory which contains 1000s of csv files that I need to parse. I have implemented the ExecutorService class of Java to do the job, wherein I assign each thread a csv file to parse. I have 4 cores in my machine. I do get some efficiency as compared to a single-threaded application. However, when I see the CPU utilization( using the task manager) it doesn't seem to be utilising all of the CPU power, the % of CPU used is just about 30%-40%. 
  I just wanted to know if my approach is correct.</p>
  
  <pre><code>File dir = new File(file);
  if(dir.isDirectory()){
      File[] files = dir.listFiles();
  
  for(File f : files){
      String file_abs_path = f.getAbsolutePath();
      int index = file_abs_path.lastIndexOf("/") + 1;
      file_name = file_abs_path.substring(index);
      futuresList.add(eservice.submit(new MyParser(file_abs_path)));
  }
  
  Object gpDocs;
  for(Future&lt;List&lt;MyObj&gt;&gt; future:futuresList) {
  try {
      docs = future.get();
      arrayList = (List&lt;MyObj&gt;)docs;
      Iterator&lt;MyObj&gt; it = arrayList.iterator();
      while(it.hasNext()){
      doc = createDocument(file_name,it.next());
      try{
          //somefunction(doc);
          }catch(Exception e){}
  }}catch (InterruptedException e) {}
  catch (ExecutionException e) {}
  }} 
  </code></pre>
  
  <p>I am just wondering if my approach is correct? Any help would be appreciated.</p>
  
  <p>Thanks</p>
  
  <p>The code for the parser is :</p>
  
  <pre><code>public List&lt;MyObj&gt; call(){
      ColumnPositionMappingStrategy&lt;MyObj&gt; strat = 
  new ColumnPositionMappingStrategy&lt;MyObj&gt;();
  strat.setType(MyObj.class);
  String[] columns = new String[] {//list of columns in the csv file}; 
  
  strat.setColumnMapping(columns);
  CsvToBean&lt;MyObj&gt; csv = new CsvToBean&lt;MyObj&gt;();
  BufferedReader reader = null;
  String doc_line = "";
  String[] docs;
  String doc = "";
  File dir = new File(file_path);
  try{
      int comma_count = 0;
      reader = new BufferedReader(new FileReader(dir));
      while((doc_line = reader.readLine()) != null){
          docs = doc_line.split(",");
      doc += docs[i] + " ";
      }
      reader.close();
      }catch (IOException e) {/*e.printStackTrace();*/}
      return(csv.parse(strat,new StringReader(doc)));
  }
  </code></pre>