• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
Can anybody pls tell me the difference between daemon and user threads?
How daemon thread is useful during execution of prog.
What's the priority of daemon thread?
Does it belongs to ThreadGroup?
 
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a daemon thread is generally a thread running in the background. The threads you create in a program are user threads unless you specify otherwise. I'm not sure the priority of a daemon thread. If there is one, I'd imagine it's pretty low.
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi!
THE DAEMON THREAD IS THREAD RUNNING IN THE BACKGROUNG BY JAVA VITUAL MACHINE.FOR EXAMPLE GARBAGE COLLECTION IS RUN BY LOW PRIORITY DAEMON THREAD OF JVM.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Daemon threads will not prevent the VM from exiting. Once all work in non-daemon threads is complete (the runs have returned), the VM will exit - so a daemon thread is most suitable for continuous tasks that support primary functions (like GC, lock sweeping, connection time-outs, etc.)
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The daemon thread, except that it is managed by JVM and will get killed if no user threads are running, is also just another thread. Therefore, just like normal threads, they will have the priority of the creating thread and the value Thread.NORM_PRIORITY by default. They will belong to the same ThreadGroup as their parent thread, unless explicitly created as belonging to another ThreadGroup using the overloaded Thread constructor. Infact you can set the entire ThreadGroup as daemon. Any threads that belong to that ThreadGroup will be marked as daemon too.

------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
reply
    Bookmark Topic Watch Topic
  • New Topic