Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As per my knowledge daemon thread is a thread that runs in background(low priority thread) and also a child thread runs in the background when the parent thread runs foreground so where does the difference lie between a child and a daemon thread?

It's in case of java and can you explain referring to other languages too.

share|improve this question

closed as too broad by Snowman, Ixrec, durron597, gnat, MichaelT Aug 31 '15 at 2:03

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

What programming language/OS are you referring to? This is important to give an answer. – Uwe Plonus Jan 9 '13 at 11:33
Its in case of JAVA and can you explain referring to other languages too. – Anji Jan 9 '13 at 11:37

Java does not use the term child thread.

A thread is either a daemon-thread or a non-daemon-thread.

A non-daemon-thread must be stopped manually and keeps the VM running as long as the thread is running.

A daemon-thread cannot keep the VM running. When the VM stops all daemon-threads will stop running.

You can group threads together with a ThreadGroup. Groups can itself be grouped together that means that you can have a parent and a child ThreadGroups.

The priority of a thread has nothing to do with the explained concepts of threads. Any thread can have any priority.

For other languages/OS I cannot tell how the concepts are there.

share|improve this answer
But a low priority thread is termed as a daemon thread isn't it? and yes a child thread is used in Unix! – Anji Jan 9 '13 at 12:10
@Anjani No, a daemon-thread may have any priority as a non-daemon-thread. The priority is an orthogonal concept in Java. – Uwe Plonus Jan 9 '13 at 12:17
Oh ok!! Thank you for specifying that. @UwePlonus – Anji Jan 9 '13 at 13:24

Daemons (or Demons) and parent | child threading concepts are orthogonal to each other. In other words, the basis of your question is wrong. Likewise, priorities can be assigned to processes and threads, but priority is orthogonal to the definition of a demon, parent thread, or child thread status.

An application is a program that has been written and becomes a process when it is executed. An application is made up of a process and zero, one, or more threads. The Wikipedia entry on Threads does a good job of explaining the difference between a process and a thread.

  • processes are typically independent, while threads exist as subsets of a process
  • processes carry considerably more state information than threads, whereas multiple threads within a process share process state as well as memory and other resources
  • processes have separate address spaces, whereas threads share their address space
  • processes interact only through system-provided inter-process communication mechanisms
  • context switching between threads in the same process is typically faster than context switching between processes.

A couple of notes -

  1. threads may or may not share the same address space, it is OS dependent.
  2. take the comment about context switching with a grain of salt - this will be OS and chipset dependent.

"Process" and "thread" are sometimes used interchangeably in conversations. It's common to call the process the "parent thread" even though this isn't technically correct since it's a process. Any thread spawning additional threads would be considered parent threads as well.

A daemon is a background process or application, generally without any interactive elements but that's not a hard requirement. A demon can have any priority assigned to it, not just low priority. In addition to the process, a daemon may have some child threads associated with it.

All of these terms are independent of the programming language used to write the application. Some languages provide better support for threads than other languages do.

share|improve this answer
Thank you so much sir,this explanation is very useful! – Anji Jan 9 '13 at 17:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.