Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

2-what is the use of thread class constructors

 
shankara me
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !last time I asked one doubt with heading “what is the use of thread class constructors”.But I could not ask that doubt in a right manner.Now I am asking the same doubt in a simple and clear manner.My doubt is on Thread class constructors. My doubts based on below simple code.In below code in main method there is a statement as ” Thread C4=new Thread (new first(),"FIRSTTHREAD");”
This Statement Will create a Thread FIRSTTHREAD for the class “first”.
Here we used Thread class constructor
public Thread(Runnable target,String name);
There are some other constructors in Thread class like
1)public Thread();
2) public Thread(String name);
The first constructor is used to create an object of Thread class.
The second constructor is used to create an object of Thread class but with required name.
Then my question is
-->What is the benefit of creating object to thread class?
-->A class named with” four” is available in below code.By using second constructor of above constructors is it possible to write “four f1=new four(“MYTHREAD”);”
----------------------------------------------------------
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shankara me wrote:-->A class named with” four” is available in below code.By using second constructor of above constructors is it possible to write “four f1=new four(“MYTHREAD”);”

What happened when you tried it ?
If you experiment and then ask specific questions if you don't understand the results of those experiments, people will be able to help you better.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic