i want the strategy for loading files by multiple threads from a single directory,without accidentally loading same file by multiple threads.
Solution:
-
Allow each thread sequentially to collect set of files to add in their data structure such as arraylist and process parallel.
-
Take the filename , anyways the last 5 digits are numbers , do a
mod(last5digit,5) +1will give1,2,3,4,5and respectively those file with mod result will be processed by correspondingThread 1,…Thread 5.
i want a solution which should not have mutual exclusion problem.kindly let me know your comments from your experience.
Essentially any thread-safe access to a list should work. I think I would: