Java. Thread execution order

I am trying to run an example from a book (Paul Hyde, Java Thread Programming). It says that the order of the threads will change. But I always get: 10 prints of "Main thread" and 10 "New thread". What's more interesting: if I use tt.run instead of tt.start, then the result will be the other way around. Maybe the reason is that the book is quite old, and the examples are based on JDK 1.2 ??? Code below:

public class TwoThread extends Thread
{
    public void run()
    {
        for (int i = 0; i < 10; i++)
        {
            System.out.println("New thread");
        }
    }

    public static void main(String[] args)
    {
        TwoThread tt = new TwoThread();
        tt.start();

        for (int i = 0; i < 10; i++)
        {
            System.out.println("Main thread");
        }
    }
}
+4
source share
2 answers

JVM , . , , JVM .

tt.run() tt.start(), . run() . "New thread".

+7

tt.run tt.start, .

tt.run main, tt.start . , .

:

, , , , . (, 10000 )

+1

Source: https://habr.com/ru/post/1607227/