Source Code : A daemon thread.
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
A daemon thread.
class MyDaemon implements Runnable {
Thread thrd;
MyDaemon() {
thrd = new Thread(this);
thrd.setDaemon(true);
thrd.start();
}
public boolean isDaemon(){
return thrd.isDaemon();
}
public void run() {
try {
while(true) {
System.out.print(".");
Thread.sleep(100);
}
}
catch(Exception exc) {
System.out.println("MyDaemon interrupted.");
}
}
}
public class Main {
public static void main(String args[]) throws Exception{
MyDaemon dt = new MyDaemon();
if(dt.isDaemon())
System.out.println("dt is a daemon thread.");
Thread.sleep(10000);
System.out.println("
Main thread ending.");
}
}
Thank with us