constructor of Thread class
package com.company;
class thr extends Thread{
public thr(String x){
super(x);
}
public void run(){
System.out.println("hello my i am a thread");
}
}
class thr1 implements Runnable{
public void run(){
System.out.println("I am in runnable");
}
}
public class CWH_73_Thread_Constructor {
public static void main(String[] args) {
// thr t=new thr("rohan");
// t.start();
// System.out.println(t.getId());
// System.out.println(t.getName());
thr1 t1=new thr1();
Thread t2=new Thread(t1);
t2.start();
System.out.println(t2.getName());
System.out.println(t2.getId());
}
}
Comments
Post a Comment