本帖最后由 郑庆伟 于 2012-7-1 23:56 编辑
class Test extends Thread
{
Test(String name)
{
super(name);
}
public void run()
{
for(int x=0; x<60; x++)
{
System.out.println((Thread.currentThread()==this)+".."+this.getName()+"run.."+x); //Thread.currentThread()跟this在使用上有什么区别吗?
}
}
}
class ThreadTest
{
public static void main(String[] args)
{
Test t1 = new Test("one---");
Test t2 = new Test("two+++");
t1.start();
t2.start();
for(int x=0; x<60; x++)
{
System.out.println("main"+x);
}
}
}
除了Thread.currentThread()是通用外还有什么区别吗?
|
|