It would be quicker to use multiple threads, yeah. One thread per file sounds good, but you still need some sort of limit (too many threads will bring a lot of problems).
My suggestion you experiment with ExecutorService
, and implement Runnable
and send in Runnables for it to run. It will automatically assign the new Runnables you send in to a Thread
when it becomes available.
You can start an ExecutorService
with a fixed number of threads simply by calling Executors.newFixedThreadPool(int numThreads)
. Then just call submit(Runnable runnableWithYourProcessing)
. Don't forget to shutdown()
when you're done!