Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

What is Demon thread and what is Green thread

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) What is Demon thread?

2) what is Green thread?

Can you one example for demon thread.

Regards
Dhinesh
 
Ranch Hand
Posts: 341
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the actual word is daemon thread but, they are sometimes referred as demon thread as they just keep on running and haunt you back

A daemon thread is a thread that exists/runs in the background. It basically is a low priority thread.
The use of daemon thread is that JVM exits when the last running thread finishes. In a GUI this typically happens when the last window is closed (which ends the dispatcher thread).If you set a Thread to daemon status then that thread doesn't prevent the JVM from exiting if it's still running.So it's used for background threads. Typically these threads speand most of their time waiting for some condition to arise which they then quietly handle. They might be waiting for an incoming socket connection. They might wake up every five minutes and check that a file hasn't been updated. They might be waiting for some task to be added to a queue which they then execute. etc. etc.

You can refer this link for more info.


A green threads is a thread that is scheduled by a JVM itself.
Wikipedia has a good description. Refer this link.
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anubhav Anand:
A daemon thread is a thread that exists/runs in the background. It basically is a low priority thread.



Not true. Daemon threads have no difference in priority to ordinary threads. You can set a daemon thread to low priority, just as you can set an ordinary thread to low priority.

The only difference between daemon threads and ordinary threads is that daemon threads are not included in the JVM's decision of when to exit.
 
Anubhav Anand
Ranch Hand
Posts: 341
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It basically is a low priority thread.



I didn't assert it , rather I told usually they are low priority( whch obviously can be altered).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic