• 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

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).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic