File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Threads and Synchronization and the fly likes implements Runnable and extending Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "implements Runnable and extending Thread" Watch "implements Runnable and extending Thread" New topic

implements Runnable and extending Thread

Mohanasundaram Govindarajan

Joined: Aug 06, 2012
Posts: 1

Which one is the best to create the Thread. i.e Implements Runnable or extends Thread.

I know that if we create thread by extending Thread class, multiple inheritance is not possible. So we can create thread by implementing Runnable to overcome this.

I want to Know if my class does not have super class , then which one is the best,Please justify.
Naishadh Parmar
Ranch Hand

Joined: Jun 02, 2011
Posts: 95

Hi Mohan,

First of all welcome to Ranch!!!
If you have to inherit a class already then I recommend "implements Runnable" because as you know a class cannot inherit multiple classes.
If you don't have to inherit any class then you can use either
Stephan van Hulst

Joined: Sep 20, 2010
Posts: 3366
No. *Always* implement Runnable. Your class is not a Thread, so it shouldn't extend it.
I agree. Here's the link:
subject: implements Runnable and extending Thread
Similar Threads
extend or implement?
How can MultiThreading is implemented in Servlets
Implementing Runnable or Extending Thread class
Why Thread class is present