import java.io.*;
import java.util.*;
class MyDaemon implements Runnable {
Thread thread;
MyDaemon() {
thread = new Thread(this);
thread.setDaemon(true);
thread.start();
}
public boolean isDaemon(){
return thread.isDaemon();
}
public void run() {
try {
while(true) {
System.out.print(".");
Thread.sleep(100);
}
} catch(Exception exc) {
System.out.println("MyDaemon thread interrupting");
}
}
}
public class DaemonThreadExample {
public static void main(String args[]) throws Exception{
MyDaemon dt = new MyDaemon();
if(dt.isDaemon())
System.out.println("Daemon thread start");
Thread.sleep(10000);
System.out.println("\nMain thread end");
}
}