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

setName() in Threads

Gajendra Kangokar
Ranch Hand

Joined: Dec 25, 2012
Posts: 65

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.

Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 136

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

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 39547
extends Thread

What do you think this accomplishes?

Generally, you should not extend Thread, but implement Runnable or a similar interface:

Ping & DNS - updated with new look and Ping home screen widget
Gajendra Kangokar
Ranch Hand

Joined: Dec 25, 2012
Posts: 65

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

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


Java Resources at
I agree. Here's the link:
subject: setName() in Threads
Similar Threads
Synchronized ?
Thread.sleep() and lock