This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes about daemon thread AND JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "about daemon thread AND JVM" Watch "about daemon thread AND JVM" New topic
Author

about daemon thread AND JVM

david hu
Ranch Hand

Joined: Jul 20, 2001
Posts: 143
It's sait that the Java Virtual Machine exits when the only threads running are all daemon threads. If the JVM exits, who is reponsible to interpret the bytecode of the daemon thread, how can these deamon thread continues running?
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Originally posted by david hu:
If the JVM exits ... how can these deamon thread continues running?

They dont. Once the JVM exits all of the daemon threads are killed and stop running.


Dave
kumar bangali
Greenhorn

Joined: Dec 01, 2001
Posts: 27
BTW What is a Daemon thread? Is it some kind of System Thread used by the JVM only?


Bos Indicus
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
The previous posts have given the definition of a daemon thread. They are used to perfomance maintining task that are not the main objective of a program, but are needed for its success.


SCJP2. Please Indent your code using UBB Code
sun ram
Ranch Hand

Joined: Dec 18, 2001
Posts: 61
Hi,
User also can create daemon thread, before starting the Thread we need to call setdaemon method with true value. If parent thread exits, deamon child threads also exit automatically.
this is how we create deamon thread.

PrimeRun p = new PrimeRun(143);
Thread t = new Thread(p);
t.setDeamon( true );
t.start();
-SR


SCSecA,SCNA,SCSA,SCWCD,SCJP
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: about daemon thread AND JVM
 
Similar Threads
exit of JVM
Daemon threads
Unclear
User & Daemon Thread
Daemon and non-daemon threads