#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Multi thread file import/process


    Hi,

    I was wondering if someone had an example of a basic multi threaded file processing?

    For example, I have a stringlist of 10 file names, and I want to process each one in a thread, exclusive reading so that no one can open/process the same file while I am.
    I also want to limit the total number of threads to 4 at a time until all the files have been processed.

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    151
    Rep Power
    3
    What you need is a pair of class. One class act as threads manager and the other is the file processing thread itself. The main functionalities of the thread manager are:
    • Provide thread safe way for the processing thread to get next file to process.
    • To spawn new processing thread when new file is added and the number of the running thread is below maximum.

IMN logo majestic logo threadwatch logo seochat tools logo