I have two folders which contain several csv files. Folder 1 has several csv files and Folder 2 has several csv files. Based on certain conditions, I am comparing csv files (code for which is present in compareCSV(File f1, File f2)) and writing into a new output file.
public void traverseThroughFiles(){
//some filename checking code
//if output is true call below function
compareCSV(File f1, File f2)
}
Now I wish to use multithreading in java so that I can process multiple files simultaneously. As per my understanding, if we could call function comapareCSV(File f1, File f2) using multiple threads then I should achieve my goal. Number of threads need to be determined by the user. But, consider numberofThreads = 5
Are there any functions/classes which are present in java that can solve my problem?
I have tried to use ThreadPool and I was unable to implement in my case. Also, how can I use ExecutorService in my case?