Hi!My doubt is on Thread class constructors
1)public Thread()
2)public Thread(String name)
The above two are two constructors of thread class.
First constructor is used to create object of thread class.
Second constructor is also used to create object of thread class with required name.
If we write
1)Thread t1=new Thread();
This creates a thread class object t1.
2)Thread t2=newThread(“MYTHREAD”);
This also creates Thread class object t2 .It also creates thread with name "MYTHREAD".
My questions are
1)What is the benefit of above t1,t2;
2)How can we use the thread class objects t1,t2?
3)Is it possible to execute run method of the thread "MYMTHREAD"?
4)Suppose we have extended class named “a” from Thread class like below.
Then how can we use t1,t2 on below class “a”?
Is it possible to create thread to below class “a” with required name by using above constructors?
Class a extends Thread
{
Public void run()
{
System.out.println(“Hi”);
}
}