> I'm new to java.
> I want to know what does main thread do when a java program is excuting!
>> I'm new to java.
>> I want to know what does main thread do when a java program is excuting!
> It calls your method
> static void main(String[] args)
and therefore runs the main method itself, and everything called from
it, directly or indirectly.
It is perhaps better to think about things that it does NOT run:
Administrative work, such a garbage collection, that the JVM chooses to
do from another thread.
Event handling.
Anything that you put in a different thread, by creating a Thread and
calling its start() method.
Patricia
Jack Dowson - 04 May 2007 14:51 GMT
Patricia Shanahan 写道:
>>> I'm new to java.
>>> I want to know what does main thread do when a java program is excuting!
[quoted text clipped - 15 lines]
>
> Patricia
Really thank you!
That means sometimes the program does not terminate when main thread is
over?Right?
Dowson.
Thomas Fritsch - 04 May 2007 17:41 GMT
[...]
> That means sometimes the program does not terminate when main thread is
> over?Right?
Yes, right!
Actually this is how all applications with a GUI (graphical user interface)
work. Their main thread usually finishes after less than one second. But
other threads continue for minutes (or even hours).

Signature
Thomas