aspose file tools*
The moose likes Threads and Synchronization and the fly likes setName() in Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "setName() in Threads" Watch "setName() in Threads" New topic
Author

setName() in Threads

Gajendra Kangokar
Ranch Hand

Joined: Dec 25, 2012
Posts: 72

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

Joined: Nov 08, 2012
Posts: 138

Are you new to Java?
The method is inherited from class Thread.


Regards,
Prajakta
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41508
    
  53
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


Ping & DNS - my free Android networking tools app
Gajendra Kangokar
Ranch Hand

Joined: Dec 25, 2012
Posts: 72

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

Joined: Mar 22, 2000
Posts: 12769
    
    5
Actually, named Threads can be helpful in debugging so this is good to explore.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setName() in Threads