Multithreading Interview Questions
We can create daemon threads in java using the thread class
setDaemon(true). It is
used to mark the current thread as daemon thread or user thread.
isDaemon()
method is generally used to check whether the current thread is daemon or not. If
the thread is a daemon, it will return true otherwise it returns false.
Example:
Program to illustrate the use of setDaemon() and isDaemon() method.
public class
DaemonThread
extends
Thread
{
public
DaemonThread
(String name){
super(name);
}
Dostları ilə paylaş: