Recursion and Threading

  • Thread starter Thread starter Sehboo
  • Start date Start date
S

Sehboo

I have written code which uses recursion to go throuh directory
stucture to search for a file. It works fine. The only problem is
that it is slow. I want to use more then one thread to do that. I am
not sure how to achieve it. I know how threading works but not sure
how to incorporate that in recursion.

Does anybody has a simple code which does that?

Thanks
 
Hi ,
the way I would do it is, for example, if you are searching in C drive
and if there are 20 folders, then you could split the work among different
threads basiccally use 5 threads and assign 4 directories to each of them
and basically you can create the threads and assisgn the same recursion
function as the thread procedure.

Thanks

Anand Balasubramanian
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks
 
While static assignment of work to threads is one way of partitioning
the task, another, and in my experience generally more flexible, is to
create some number of worker threads (the number depending on the
machine and problem - to many and things go slower, to few and you
give away some performance) all feeding off of a work queue. Such
systems tend to self load balance reasonably well.

In a case where you are going to walk a file system, as seems the case
here, it is worth remembering that it is easy to thrash the disk
drive and make things slower by having multiple threads depending on
the nature of the file system and location of the files on the disk.
One possible control for this is to have the threads turn themselves
on and off in response to total system throughput.

Richard
 
Back
Top