In Java if I have a class that creates threads from the constructor (by calling some functions of that class) and I create an object of that class in my main method. Does the main method wait until all the threads are done or does it continue to the next line?
for example:
public static void main(String[] args) {
WorksWithThreads obj = new WorksWithThreads ( );
//does something else - does this line happen after all the 9 threads finished their job?
}
class WorksWithThreads(){
public WorksWithThreads(){
for(int i=0;i<9;i++)
WithThread tread= new WithThread();
}
private static class WithThread extends Thread {
public WithThread () {
run();
}
public void run(){
//does something
}
}
}
I hope I was not too confusing.. Thank you in advance.. Shiran