I have 2 text files and 2 threads in my porgram. My task is i need to allow only one thread to execute a one file. If thread1 executed the first text file then thread2 is not supposed to execute the first text file because it is already processed by first thread but at the same time thread2 is supposed to execute the second text file if the file is not processed by first thread. In the same way if second text file is already proccessed by thread2 then thread1 is not supposed to process the second text file.
Finally what i want to do is,
i want to process a one text file with one thread, if the text file is already processed by the first thread then second thread is not supposed to process the file, whatever the files are left out by the thread1 that files are only supposed to process by the thread2.
Can any one please let me know how to achieve it???
A general solution would be to set up a queue for the file names, and a thread pool to process the files, but it may be an overkill for your problem. It'd allow you to process any number of files with any number of threads.