This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Well, I guess you could say a Servlet runs as a thread, as does an EJB, as does many other resources. But these resources are different enough from a thread that is spawned in a program that we treat them differently. I guess we don't need to start a thread when we call main for the same reason we don't when a servlet is invoked - it's because the runtime is just smart enough to do it for us.
the main thread is usually started by JVM, after class-loader finished loading main class. You can try to change the signature of main method (or even delete it) and then run the class. You will get a NoSuchMethodError, because JVM didn't find an appropriate method signature.
SCJP 6.0(95%), SCWCD 5(94%), SCJD (working on B&S v.2.3.1)
whenever you give a class file to the JVM.....it looks for the main method in other words main method is an entry for the JVM to your code and that entry is searched in the public class as its name is same as the file.
So when the JVM enters your code as new stack for that thing materializes....if you enter something there should be some room in there to run things that it has. So a new thread for it starts with its own stack memory.
Also in threads when you run the start() method the new stack for the thread materializes.
[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api