public class Main {
public static void main(String[] args) throws InterruptedException {
Thread t = new Thread(() -> {
System.out.println("hello");
});
t.start();//把这行代码放到了下面这行代码前面
System.out.println("start");
t.join();
System.out.println("end");
}
}
反复执行结果如下:
start
hello
end
说明了t.start()执行以后,首先执行的仍然是 main线程,再是t线程,最后再切换到main线程
_我是来微博看美女的