Friday, April 12, 2019

daemon thread

public class cl extends Thread{
 public void run(){
  if(Thread.currentThread().isDaemon()){
   System.out.println("daemon thread");
  }
  else{
  System.out.println("user thread ");
 }
 }
 public static void main(String[] args){
  cl t1=new cl();
  cl t2=new cl();
  cl t3=new cl();

  t1.setDaemon(true);
 
  t1.start();
  t2.start();
  t3.start();
 }
}

$javac cl.java
$java -Xmx128M -Xms16M cl
daemon thread
user thread 
user thread 

No comments:

Post a Comment