class test1 extends Thread
{
public void run()
{
System.out.println("Run method executed by child Thread");
}
public static void main(String[] args)
{
test1 t = new test1();
t.start();
System.out.println(726*656);
System.out.println("Main method executed by main thread");
}
}
输出是-
476256
Main method executed by main thread
Run method executed by child Thread
为什么线程语句最后出现,即使我先调用启动方法也是如此
当您调用start时,新线程开始执行,但是不会影响已经在执行的Main线程。如果希望主线程等待新线程,则可以在新线程上调用“ join”之类的方法以等待其完成