• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setName() in Threads

 
Gajendra Kangokar
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the below code where class extends thread,at line number 16 setName("Thread") method is called when there is no such method defined in this class.
My question is,how is the code still working with proper output.


Thanks
 
Prajakta Acharya
Ranch Hand
Posts: 138
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you new to Java?
The method is inherited from class Thread.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
extends Thread


What do you think this accomplishes?

Generally, you should not extend Thread, but implement Runnable or a similar interface: https://www.coderanch.com/how-to/java/ExtendingThreadVsImplementingRunnable
 
Gajendra Kangokar
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you new to Java?

yes somewhat new!!very new to Threads atleast.

What do you think this accomplishes?

i am trying to learn threads and this was just a example to learn and thanks for the usefull link
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, named Threads can be helpful in debugging so this is good to explore.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic