Apache POI InvocationTargetException Processing files over network slows down programs
Jan 24

There are a few other things i wanted to share. I actually use the java.util.concurrent.ThreadPoolExecutor to copy files. For those using Java 1.4, here is your gateway to concurrency :  http://backport-jsr166.sourceforge.net/

Here goes my ThreadPool code. You surely could write better code than this.

LinkedBlockingQueue archiverTaskQueue = new LinkedBlockingQueue();
ThreadPoolExecutor archiverExecutor = new ThreadPoolExecutor(50, MAXTHREADS, 50000L, TimeUnit.MILLISECONDS,archiverTaskQueue);
File tempCurrentFile=new File(tempDestinationDir, archiveFileName);
archiver = new Archiver(tempCurrentFile, new File(actualDestinationDir, fileName));
archiverExecutor.execute(archiver);
 

Forgot to mention, I use NIO to copy files. I understand that there are people for and against NIO. My reason for using NIO is just it sounded exciting.

Source code : Archiver.java

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • description
  • Furl
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • TwitThis

Tags: , , , , , , , , ,

Leave a Reply