*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What is a daemon/non-daemon thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What is a daemon/non-daemon thread" Watch "What is a daemon/non-daemon thread" New topic
Author

What is a daemon/non-daemon thread

leena rane
Ranch Hand

Joined: Aug 13, 2001
Posts: 280
What r daemon/non-daemon threads?
In complete reference,it is written that main thread should be the last thread to finish,so use join(),but elsewhere it is written that JVM exits only when all non-daemon threads are dead.
I had a program where main thread throws an exception,and the thread it creates finishes quite later,but creates all the expected output.Then condition of complete ref. is not satisfied.
I think i have the concepts wrong.
Can u help me,
thanx in advance,
best regards
leena
INDU, BALA
Ranch Hand

Joined: Jun 07, 2001
Posts: 48
Hi leena,
Hope this discussion helps
http://www.javaranch.com/ubb/Forum24/HTML/001830.html

Indu
leena rane
Ranch Hand

Joined: Aug 13, 2001
Posts: 280
Thanx a lot Indu,
take care,
leena.
vidhya subramaniam
Ranch Hand

Joined: Jul 14, 2001
Posts: 91
When you dont want the main program to wait for the thread to end you set the code as setDaemon(true).
The JVM does not exist until all the non Daemon threads finish executing. Garbage collector is a non Daemon thread.

vidhya
leena rane
Ranch Hand

Joined: Aug 13, 2001
Posts: 280
Thanx Vidya
>The JVM does not exit until all the non Daemon threads finish >executing. Garbage collector is a non Daemon thread.
can u further explain me about garbage collector thread.
Does it mean the program jvm will not exit until garbage collector thread completes it's work.
Also what is the difference between:
jvm exits only when ........
and interpreter exits only when ...........
thanx in advance,
Best Regards ,
leena
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is a daemon/non-daemon thread
 
Similar Threads
Demon Threads
Interesting Ques in Threads?????
Daemon Thread
Help! Must prevent termination of one app when second app is terminated
Threads