What is daemon thread?

What is daemon thread?

Threads that work in the background to support the runtime environment are called daemon threads. Daemon threads are typically used to perform services for your application/applet. The virtual machine exits whenever all non-daemon threads have completed. Two methods are used in this context: 

  public final void setDaemon(boolean isDaemon)
  public final boolean isDaemon()

By default a thread you create is not a daemon thread. However you can use the setDaemon(true) method to turn it into one. Daemon thread is a low priority thread which runs in the back ground doing the garbage collection operation for the java runtime system.

Date:2015-01-09 00:00:00

Post Your Answers

User Email:

User Name:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher