Input
Output
public class DaemonThread extends Thread { public void run() { if(Thread.currentThread().isDaemon()){ System.out.println("Daemon Thread"); } else{ System.out.println("Normal Thread"); } } public static void main(String[] args) throws Exception { DaemonThread t = new DaemonThread(); System.out.println("Current thread is " + t.currentThread()); t.setDaemon(true); t.start(); } }