线程向左,我向右.
各位高手大哥,小弟一直有个疑惑在下面的问题当中,请各位大哥给看看.......
public class TwoThread extends Thread{
private Thread creatorTread;
public TwoTread(){
creatorThread=Thread.currentThread();
}
public void run(){
for(int i=0;i<10;i++){
printMsg();
}
}
public void printMsg(){
Thread t=Thread.currentThread();
if(t==creatorThread){
System.out.println("Creator thread");
}else if(t==this){
System.out.println("New thread");
}else{
System.out.println("Mystery thread--unexpected!");
}
}
public static void main(String[] args){
TwoThread tt=new TwoThread();
tt.start();
for(int i=0;i<10;i++){
tt.printMsg();
}
}
}
我的疑问是:这里的this是什么,我的主线程打印的是那句话:"Creator thread"?"New thread"?