Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


I am confused?

Posted on 1999-07-27
Medium Priority
Last Modified: 2010-04-16
I am confused. The online java tutorial has a line that says:
"The first way to customize what a thread does when it is running is to subclass Thread (itself a Runnable object)"
Again at the point where applets and multithreading is concerned, it asks you to implement the Runnable interface.
As far as I know, an interface contains a set of function declarations and constants. The implementation of those functions are to be provided in the class which implements that interface.
Also an object is an instance of a class.
So if there is a Runnable object, then there should be a Runnable class somewhere in the java language. Again there is also a Runnable interface. Are they the same? What really is meant in the tutorial when they spoke of Runnable objects? Please post your answers in context with the contents of the tutorial.
Question by:rhea
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

shlomoy earned 80 total points
ID: 1247243
The Runnable is not a class but an interface. This means that there are many implementations of Runnable (all Threads which actually implement Runnable are such).

You are advised to implement the Runnable interface instead of extending the Thread class when you want to write an applet because you can't inherit from more than one object in Java. Since you have no choice but extending the Applet class, you only have the option of implementing Runabble if you want if to have threading capabilities.

The class Thread actually implements the Runabble interface too!

if are still not clear about this, just say so. I'll explain more.


Author Comment

ID: 1247244
Then what is actually meant by 'Runnable object' in the online Java tutorial at
The exact line is:
"The first way to customize what a thread does when it is running is to subclass Thread (itself a Runnable object)"
How can an interface be an object?

Expert Comment

ID: 1247245
An interface is not an object.
You should consider an interface like a contract.
it is the set of method that the "implementing" object (in our case - any threading object) MUST implement.

the meanin of "a runnable object" is, IMO, an object which implements the runnable interface. nothing more than that.


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.


Author Comment

ID: 1247246
Does IMO stand for Implementing Method Object.


Expert Comment

ID: 1247247
IMO - Shlomoy probably meant "in my opinion".

Interfaces are Java's mechanism for implementing the object oriented programming concept of multiple inheritance. One example given in OOP classes is a base class called Fruit. You could sub-class Fruit with classes called Banana, Orange, etc.  You could also have objects like Orange implement an interface called Spherelike, which might have methods like getCircumference() and roll(); Round fruits could implement this interface, but so could another round object like a Tire.

With multithreading you have the option of subclassing Thread. When you write an applet you typically subclass java.applet.Applet, so subclassing Thread to implement multithreading is not possible. That is why there is a Runnable interface, so you can subclass Applet and still write a run() method for multithreading.

Expert Comment

ID: 1247248
thanks, dorothy2, for that explenation! :-)

Author Comment

ID: 2020695

Expert Comment

ID: 6830748
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.
Thank you,
Moderator @ Experts Exchange

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question