本帖最后由 杨长川 于 2013-3-27 13:31 编辑
- 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()是通用外还有什么区别吗?
|