When the following code is run, it launches the thread r, as the output from it is received but the test phrase is never outputted though there are no errors outputted that would suggest an error. Why is this not able to progress past the thread launch? Will it wait for the thread to be stopped before continuing?
while(x<y){
Runnable r = new Rule1(2, 0);
new Thread(r).start();
System.out.println("value of x is: " + x);
x++;
}
I have modified the rule1 method so that in completes sooner. Once it completes then the "value of x is" string is written to the console. This would imply that my main method is waiting for the completion of the thread. I thought that by launching a thread it would run separately allowing both the main and the new thread to run simultaneously. Am i wrong in this assumption? This a sample of the code for rule1
public class Rule1 implements Runnable {
public Rule1(int z, int q){
//do stuff
}
public void run(){
}
}