check this modified code:
class fort extends Thread {
public void start(){
super.start();
for (int i=0; i<100;i++) System.out.println("in start");
}
public void run() {
for (int i=0; i<100;i++) System.out.println("in run");
}
public static void main(String args[]){
fort t = new fort();
t.start();
}
}
so I think it's just because the println("in start"); get the cpu slightly earlier.
Originally posted by Cameron Park:
I don't understand why is "in start" printed before "in run"? Shouldn't super.start() print "in run" when it invoke run(), then "in start" was printed?
Thanks.