Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Query:What does main thread do in java?

Reply
Thread Tools

Query:What does main thread do in java?

 
 
Jack Dowson
Guest
Posts: n/a
 
      05-04-2007
Hello Everybody:
I'm new to java.
I want to know what does main thread do when a java program is excuting!
Thanks in advance!
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      05-04-2007
Jack Dowson wrote:
...
>I'm new to java.


A good group for those new to Java, is
comp.lang.java.help
but even there..

>I want to know what does main thread do when a java program is excuting!


you will be expected to read your textbooks, do a
bit if googling, and ask a smart question.
<http://www.catb.org/~esr/faqs/smart-questions.html>

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.asp...neral/200705/1

 
Reply With Quote
 
 
 
 
pundeerd pundeerd is offline
Junior Member
Join Date: May 2007
Posts: 6
 
      05-04-2007
The main thread is non daemon thread is invoked by JVM to execute the application.It is responsible for pushing/pulling values of variables to/from stack to do intermediate calculations,managing Program Counter within JVM.

Read more...
 
Reply With Quote
 
Thomas Fritsch
Guest
Posts: n/a
 
      05-04-2007
Jack Dowson wrote:
> 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)

--
Thomas
 
Reply With Quote
 
Patricia Shanahan
Guest
Posts: n/a
 
      05-04-2007
Thomas Fritsch wrote:
> Jack Dowson wrote:
>> 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
 
Reply With Quote
 
Jack Dowson
Guest
Posts: n/a
 
      05-04-2007
Patricia Shanahan 写道:
> Thomas Fritsch wrote:
>> Jack Dowson wrote:
>>> 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

Really thank you!
That means sometimes the program does not terminate when main thread is
over?Right?

Dowson.
 
Reply With Quote
 
Thomas Fritsch
Guest
Posts: n/a
 
      05-04-2007
Jack Dowson wrote:
[...]
> 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).

--
Thomas
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Thread[pool-1-thread-2,5,main] - What does this mean? Hugo Java 4 03-27-2008 01:42 AM
adding main.aspx.vb & main.aspx.resx under aspx John M ASP .Net 1 05-29-2005 09:27 PM
Terminating a thread from the main thread Charles A. Lackman ASP .Net 3 12-09-2004 02:12 PM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM



Advertisments