title: Speedup a Java application
body: <p>How to Speedup a Java application?</p>
  
  <p>I am working on an Java application, which parse Cobol files line by line, extract the necessary data from them and populate into DB2 database.</p>
  
  <p>If there are more files to parse, then the application takes more than 24 hrs to complete, which is not acceptable. </p>
  
  <p>So I do some table population in a separate thread for speedup ..e.g.</p>
  
  <pre><code>ArrayList list = (ArrayList)vList.clone();
  ThreadPopulator populator = new ThreadPopulator(connection, list, srcMbr);
  Thread thread = new Thread(populator);
  thread.run();
  return;
  
  
  And ThreadPopulator class is implementing Runnable interface and run method as
  
  public void run()
  {
      try
      {
          synchronized (this)
          {
             int len = Utils.length(list);
             for (int i = 0; i &lt; len; i++)
             {
                .....
                stmt.addBatch();
              if ((i + 1) % 5000 == 0)
                      stmt.executeBatch(); // Execute every 5000 items.
             }
          }
      }
      catch (Throwable e)
      {
          e.printStackTrace():
      }
      finally
      {
          if (list != null)
              list.clear();
      }
  }
  </code></pre>
  
  <p>Note: Need to use clone, so that next thread can't vanish the entries.</p>
  
  <p>Am I thinking in right way?</p>
  
  <p>Please suggest me, what the way I have to choose to speedup my application over a thousands of Cobol file. </p>