Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Daemon threads

 
natarajan meghanathan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a doubt. Does all threads created by the JVM are daemon threads?. I think it is true. Can anybody help me to resolve this!
TIA
 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No unless you issue a method setDeamon(true) then the thread becomes deamon(user Threads)
 
natarajan meghanathan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
user threads are non-daemon threads. What i wanted to know is that whether all the threads run by the JVM on the background (eg. we know gc is a daemon thread) are daemon threads.
 
Val Dra
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok i dind' tget your question , and i am not doing well with threads yet. But is this a user Thread if i create my own ?
Thread d = new Thread(this);
d.setDeamon(true);
d.start();
Now is this a deamon thread ? I believe it comes a deamon and isn't it a user thread ?
 
Priya Kannan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
All the threads spanned by JVM are not Daemon threads.
Eg: main()
 
Priya Kannan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Val,
Yep.It's a 'user' turned 'Daemon'!!!
 
Vijay pillai
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi priya,
main thread is not a demon thread,but what about other threads that run in the background.
eg the ReferenceHandler thread,the Signal dispatcher thread etc.... as the JVM is said to start four threads for an application in the absence of a GUI.
could u please throw some light on this.
Vijay Pillai
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic