Daemon Threads in Java Programming
Daemon Threads in Java Programming
A Daemon threads are those threads which is used as service providers like in Java GarbageCollector is a daemon thread.
Any Java thread can be a daemon thread. To specify that a thread is a daemon thread, call the setDaemon method with the argument true. To determine if a thread is a daemon thread use method isDaemon.
public class User DaemonThread{
public static void main(String[] args){
Thread t = new Thread(new DaemonThread());
t.setDaemon(true);
t.start();
try{
Thread.sleep(150);
}catch(InterruptedException ei)
System.err.println(ei);
}
}
}
class DaemonThread implements Runnable{
}
public void run(){
}
}