[concurrency-interest] Recursive Directory checker

Aleksandar Lazic al-javaconcurrencyinterest at none.at
Fri Feb 24 10:59:35 EST 2012


Dear list members,

I'm on the way to write a directory counter.

I'm new to all this thread/fork stuff, so please accept my apologize
for such a 'simple' question ;-)

What is the 'best' Class for such a program.

ForkJoinTask
RecursiveAction
RecursiveTask

I plan to use for the main program.

pseudocode
###
main:

  File startdir = new File("/home/user/");
  File[] files = file.listFiles()

  add directories to the Queue.

-----
I'm unsure which Queue is the best for this?

http://gee.cs.oswego.edu/dl/jsr166/dist/docs/java/util/Queue.html

I tend to BlockingDeque
-----

   ForkJoinPool fjp = new ForkJoinPool(5);

   foreach worker
     get filesizes and $SummAtomicLong.addAndGet(filesizes);

print "the Directory and there subdirs have {} Mbytes", $SummAtomicLong

####

Worker:

   foreach directory
     if directory is not in queue
       add directory to the Queue.

   foreach file
     add filesize to $workerAtomicLong.addAndGet(file.size);
###

I hope it is a little bit clear what I want to do ;-)

No this is not a Homework ;-)

Should I use a global variable for the SummAtomicLong?
Should I use a global variable for the DirectoryQueue?

I expect that there are not more then 
'ForkJoinPool(5)'-Threads/Processes which work
on the disk, is that right?

I have try to understand some of the

http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/test/loops/

but I have still some questions.

Many thanks for all your help.

Cheers
Aleks


More information about the Concurrency-interest mailing list