Hi all,
I got the following question and also the answer,
but I can't get the proper meaning out of this answer, can anybody please explain me, and if possible please give some coding example.
Q: 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?
Answer: Absolutely wrong!
The correct one:
When you start a program, 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 program spawns new threads from the main thread it does stop
until last thread id died.
Even if the main thread dies program keep running.
Thanks in advance
Srinivasa Vallabha