package com.JavaInterview.Programs;
/**
* *You
can make any java thread as daemon thread. Daemon threads acts like service
providers
*
for other threads running in the same process.Daemon threads will be
terminated by the
*
JVM when there are none of the other threads running, it includes main
thread of execution
*
as well.
*
*/
public
class DaemonThread extends Thread{
public DaemonThread(){
setDaemon(true);
}
public void run(){
System.out.println("Is this thread Daemon? -
"+isDaemon());
}
public static void main(String a[]){
DaemonThread dt = new DaemonThread();
// you can set daemon constrain here also
// it is like dt.setDeamon(true)
dt.start();
}
}
Output:
Is this thread Daemon? - true