Trying to write a multithreaded java program but running into some issues, my primary multithreaded class works fine but if i call it from main it starts all the threads and moves on to the next function, i need it to not move on untill ALL threads are done. read gets passed file paths read(String, String)
Thread one = new Thread(new Runnable() {
public void run()
{
System.out.println("Starting thread 1");
read(expiredOneYear, master1);
System.out.println("Finished thread 1");
}
});
Thread two = new Thread(new Runnable() {
public void run()
{
System.out.println("Starting thread 2");
read(expiredOneAndQuarterYear, master2);
System.out.println("Finished thread 2");
}
});
Thread three = new Thread(new Runnable() {
public void run()
{
System.out.println("Starting thread 3");
read(expiredOneAndHalfYear , master3);
System.out.println("Finished thread 3");
}
});
Thread four = new Thread(new Runnable() {
public void run()
{
System.out.println("Starting thread 4");
read(expiredOneAnd3QuarterYear , master4);
System.out.println("Finished thread 4");
}
});
// start threads
one.start();
two.start();
three.start();
four.start();
below is what happens in main
CSVcompare.run(threadCount, mode, fileLocation);
CSVpattern.run(fileLocation);
I don't want CSVpattern.run() to start untill ALL threads in CSVcompare.run() have finished, otherwise it won't have certain data ready for CSVpattern.run()