| Author |
How is main a thread
|
Harvinder Singh
Ranch Hand
Joined: Feb 14, 2003
Posts: 90
|
|
Hi Java'sSocialWorkers:-), A class that has a main() method may or may not implement the Runnable Interface or extend the Thread class then how the main() is called the first non-daemon thread that JMV runs when the class is loaded.further the JVM only calls the run() method of the class to which the thread belongs.
|
Hard work beats talent<br />when talent doesn't work hard.<p> - Tim Notke
|
 |
Jose Botella
Ranch Hand
Joined: Jul 03, 2001
Posts: 2120
|
|
|
The thread that executes an application has been named "main" because it executes the code in the main method. The class holding the main method is not otherwise related to this thread.
|
SCJP2. Please Indent your code using UBB Code
|
 |
Marlene Miller
Ranch Hand
Joined: Mar 05, 2003
Posts: 1391
|
|
How is main a thread? Even if the virtual machine is not actually coded this way, it seems like a reasonable way the virtual machine could start the main thread: The idea here is that the virtual machine (theoretically) creates a Runnable object that invokes the static method main. Then it creates a Thread object and passes that Runnable object as the thread target. Notice how this can explain why we can throw checked exceptions from main(). Why am I spreading such myths? Until I find out how it really works, this is how I explain to myself how the main thread is just like any other thread. But I defer to Jose, our virtual machine expert. [ October 06, 2003: Message edited by: Marlene Miller ]
|
 |
 |
|
|
subject: How is main a thread
|
|
|