This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is a daemon/non-daemon thread

 
leena rane
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi leena,
Hope this discussion helps
http://www.javaranch.com/ubb/Forum24/HTML/001830.html

Indu
 
leena rane
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx a lot Indu,
take care,
leena.
 
vidhya subramaniam
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic