原理上不分先后,但系统实现上肯定是第二个。
因为thread.start()后马上就输出了第二行,而thread.start只是通知操作系统启动另外一个线程甚至进程,肯定要多花一些时间才等到线程真正启动。
因为thread.start()后马上就输出了第二行,而thread.start只是通知操作系统启动另外一个线程甚至进程,肯定要多花一些时间才等到线程真正启动。
调试欢乐多
Runnable r1=new Xing();
Thread t1=new Thread(r1);
用 Thread t1=new Thread(this,"thread"); 取代行不行?
Thread t1=new Thread(this,"thread");
程序报错:Xing.java:9: non-static variable this cannot be referenced from a static context Thread t2=new Thread(this,"thread");
^
1 error请告诉我为什么?
现在这里是Main()本身是一个线程,而程序中这个线城最先启动了,而另外一个再后面才启动的