I read this statement:
The main thread must be the last thread to finish execution. When the main thread stops, the program terminates.
Is it true?
I also came to know "Even if the main thread dies, the program keeps running".
This is my current understanding:
- When you start a program, the JVM creates one thread to run your program.
- The JVM creates one user thread for running a program. This thread is called main thread.
- The
main
method of the class is called from the main thread. - If a program spawns new threads from the main thread, the program waits until the last thread dies.
Which one is true?