Constructors from Thread class in Java
package com.company;
class MyThr extends Thread{
public MyThr(String name){
super(name);
}
public void run(){
// while(true){
// System.out.println("I am a thread");
// }
}
}
public class tuts {
public static void main(String[] args) {
MyThr t = new MyThr("Aryan");
t.start();
System.out.println("The id of thread t is " + t.getId());
System.out.println("The name of thread t is " + t.getName());
}
}
Comments
Post a Comment