public class DaemonThread extends Thread {
@Override
public void run() {
System.out.println("inside user created thread");
if (Thread.currentThread().isDaemon()) {
System.out.println("It is a Daemon Thread");
} else {
System.out.println("It is not a daemon thread");
}
}
public static void main(String[] args) {
System.out.println("main thread");
//We can not set a thread as daemon thread after running
//that why this will give exeption for main
//i.e we can not set main thread as deamon thread
//Thread.currentThread().setDaemon(true);
DaemonThread dt = new DaemonThread();
dt.setDaemon(true);
dt.start();
// System.out.println(dt.isAlive());
}
}