I am confused?

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.
Who is Participating?
shlomoyConnect With a Mentor Commented:
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.

rheaAuthor Commented:
Then what is actually meant by 'Runnable object' in the online Java tutorial at http://www.javasoft.com
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?
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.

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

rheaAuthor Commented:
Does IMO stand for Implementing Method Object.

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.
thanks, dorothy2, for that explenation! :-)
rheaAuthor Commented:
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
All Courses

From novice to tech pro — start learning today.