Look at the codes below, it always shows "Main Thread Done".
private static class Person{
private String name;
}
public static void main(String[] args) throws InterruptedException {
final Person person = new Person();
new Thread(()->{
System.out.println("new Thread Done");
//person.name = "Jack";
}).start();
//person.name = "Tom";
System.out.println("Main Thread Done");
//System.out.println(person.name);
}
My question is, why does the main thread always run faster than new thread? Is it possible for result "new Thread Done"? I've tried on Windows, CentOS, macOS, both "Main Thread Done". I didn't find any documents said that main thread in java always faster than any others.