Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Daemon Threads  RSS feed

 
Parijat Mukherjee
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a daemon thread group ? When and why it is used.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daemon thread is a thread which is used for background processes. Daemon threads are service providers for other threads running in the same process as the daemon thread.
Examples include garbage collection thread , screen refresh threads.
Daemon thread continue to run as long as the users thread (non daemon) runs.
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Parijat
ThreadGroup
are not very used. They group threads and other ThreadGroups.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both Pradeep and Jose are correct. However...
A daemon ThreadGroup is different than a daemon Thread. A daemon ThreadGroup is one that is automatically destroyed as soon as no thread it directly contains is running, and the last ThreadGroup it contains is destroyed.
It would be used if you wanted to group threads together to control their priority or security, and the group should be removed altogether when all the threads are done. If you created a ThreadGroup for each client of a server, for example, then a daemon ThreadGroup would make good sense.
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ernerst!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!